diff --git a/examples/darwin-framework-tool/main.mm b/examples/darwin-framework-tool/main.mm index 8c96d490dc5ed8..268c0b697da253 100644 --- a/examples/darwin-framework-tool/main.mm +++ b/examples/darwin-framework-tool/main.mm @@ -30,7 +30,7 @@ #include "commands/storage/Commands.h" #include -#include +//#include int main(int argc, const char * argv[]) { @@ -45,7 +45,6 @@ int main(int argc, const char * argv[]) registerCommandsPayload(commands); registerClusterOtaSoftwareUpdateProviderInteractive(commands); registerCommandsStorage(commands); - registerCommandsTests(commands); registerClusters(commands); return commands.Run(argc, (char **) argv); } diff --git a/examples/darwin-framework-tool/templates/tests/commands.zapt b/examples/darwin-framework-tool/templates/tests/commands.zapt index 526e33f5edd497..8f6638953a8174 100644 --- a/examples/darwin-framework-tool/templates/tests/commands.zapt +++ b/examples/darwin-framework-tool/templates/tests/commands.zapt @@ -41,23 +41,3 @@ public: {{>test_cluster tests="manualTests.json" credsIssuerConfigArg=false}} #endif // CONFIG_ENABLE_YAML_TESTS - -void registerCommandsTests(Commands & commands) -{ - const char * clusterName = "Tests"; - - commands_list clusterCommands = { -#if CONFIG_ENABLE_YAML_TESTS - make_unique(), - make_unique(), - {{#chip_tests "ciTests.json" includeAllClusters=true}} - make_unique<{{filename}}>(), - {{/chip_tests}} - {{#chip_tests "manualTests.json" includeAllClusters=true}} - make_unique<{{filename}}>(), - {{/chip_tests}} -#endif // CONFIG_ENABLE_YAML_TESTS - }; - - commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for running YAML tests."); -} diff --git a/examples/darwin-framework-tool/templates/tests/templates.json b/examples/darwin-framework-tool/templates/tests/templates.json index 9ca4d2e533c183..40c107832e31db 100644 --- a/examples/darwin-framework-tool/templates/tests/templates.json +++ b/examples/darwin-framework-tool/templates/tests/templates.json @@ -51,12 +51,5 @@ "name": "maybeCheckExpectedConstraints", "path": "partials/checks/maybeCheckExpectedConstraints.zapt" } - ], - "templates": [ - { - "path": "commands.zapt", - "name": "Tests Commands header", - "output": "test/Commands.h" - } ] } diff --git a/scripts/tools/zap_regen_all.py b/scripts/tools/zap_regen_all.py index 0b89b661ee31c5..fe7a039ea5c62f 100755 --- a/scripts/tools/zap_regen_all.py +++ b/scripts/tools/zap_regen_all.py @@ -60,7 +60,6 @@ class TargetType(Flag): __TARGET_TYPES__ = { - 'tests': TargetType.TESTS, 'global': TargetType.GLOBAL, 'idl_codegen': TargetType.IDL_CODEGEN, 'specific': TargetType.SPECIFIC, @@ -446,25 +445,6 @@ def getCodegenTemplates(): return targets -def getTestsTemplatesTargets(test_target): - zap_input = ZapInput.FromPropertiesJson('src/app/zap-templates/zcl/zcl.json') - templates = { - 'darwin-framework-tool': { - 'template': 'examples/darwin-framework-tool/templates/tests/templates.json', - 'output_dir': 'zzz_generated/darwin-framework-tool/zap-generated' - } - } - - targets = [] - for key, target in templates.items(): - if test_target == 'all' or test_target == key: - logging.info("Found test target %s (via %s)" % - (key, target['template'])) - targets.append(ZAPGenerateTarget(zap_input, template=target['template'], output_dir=target['output_dir'])) - - return targets - - def getGoldenTestImageTargets(): return [GoldenTestImageTarget()] @@ -494,9 +474,6 @@ def getSpecificTemplatesTargets(): def getTargets(type, test_target): targets = [] - if type & TargetType.TESTS: - targets.extend(getTestsTemplatesTargets(test_target)) - if type & TargetType.GLOBAL: targets.extend(getGlobalTemplatesTargets()) diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h deleted file mode 100644 index 64fae4505f0655..00000000000000 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ /dev/null @@ -1,193675 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#pragma once - -#if CONFIG_ENABLE_YAML_TESTS - -#include -#include -#include -#include - -#include // For INFINITY - -typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); - -class TestList : public Command { -public: - TestList() - : Command("list") {}; - CHIP_ERROR Run() override - { - printf("TestAccessControlCluster\n"); - printf("Test_TC_ACL_1_1\n"); - printf("Test_TC_ACL_2_1\n"); - printf("Test_TC_ACL_2_3\n"); - printf("Test_TC_ACE_1_1\n"); - printf("Test_TC_ACE_1_5\n"); - printf("Test_TC_AIRQUAL_1_1\n"); - printf("Test_TC_AIRQUAL_2_1\n"); - printf("Test_TC_BOOL_1_1\n"); - printf("Test_TC_BOOL_2_1\n"); - printf("Test_TC_BRBINFO_1_1\n"); - printf("Test_TC_ACT_1_1\n"); - printf("Test_TC_BIND_1_1\n"); - printf("Test_TC_CC_1_1\n"); - printf("Test_TC_CC_2_1\n"); - printf("Test_TC_CC_3_2\n"); - printf("Test_TC_CC_3_3\n"); - printf("Test_TC_CC_4_1\n"); - printf("Test_TC_CC_4_2\n"); - printf("Test_TC_CC_4_3\n"); - printf("Test_TC_CC_4_4\n"); - printf("Test_TC_CC_5_1\n"); - printf("Test_TC_CC_5_2\n"); - printf("Test_TC_CC_5_3\n"); - printf("Test_TC_CC_6_1\n"); - printf("Test_TC_CC_6_5\n"); - printf("Test_TC_CC_7_3\n"); - printf("Test_TC_CC_7_4\n"); - printf("TestColorControl_9_1\n"); - printf("TestColorControl_9_2\n"); - printf("Test_TC_CDOCONC_1_1\n"); - printf("Test_TC_CDOCONC_2_1\n"); - printf("Test_TC_CMOCONC_1_1\n"); - printf("Test_TC_CMOCONC_2_1\n"); - printf("Test_TC_FLDCONC_1_1\n"); - printf("Test_TC_FLDCONC_2_1\n"); - printf("Test_TC_NDOCONC_1_1\n"); - printf("Test_TC_NDOCONC_2_1\n"); - printf("Test_TC_OZCONC_1_1\n"); - printf("Test_TC_OZCONC_2_1\n"); - printf("Test_TC_PMHCONC_1_1\n"); - printf("Test_TC_PMHCONC_2_1\n"); - printf("Test_TC_PMICONC_1_1\n"); - printf("Test_TC_PMICONC_2_1\n"); - printf("Test_TC_PMKCONC_1_1\n"); - printf("Test_TC_PMKCONC_2_1\n"); - printf("Test_TC_RNCONC_1_1\n"); - printf("Test_TC_RNCONC_2_1\n"); - printf("Test_TC_TVOCCONC_1_1\n"); - printf("Test_TC_TVOCCONC_2_1\n"); - printf("Test_TC_OPCREDS_1_2\n"); - printf("Test_TC_BINFO_1_1\n"); - printf("Test_TC_CNET_1_3\n"); - printf("Test_TC_DESC_1_1\n"); - printf("Test_TC_DLOG_1_1\n"); - printf("Test_TC_DGETH_1_1\n"); - printf("Test_TC_DGETH_2_1\n"); - printf("Test_TC_DGETH_2_2\n"); - printf("Test_TC_FLW_1_1\n"); - printf("Test_TC_FLABEL_1_1\n"); - printf("Test_TC_FAN_1_1\n"); - printf("Test_TC_FAN_2_1\n"); - printf("Test_TC_FAN_2_2\n"); - printf("Test_TC_FAN_2_3\n"); - printf("Test_TC_FAN_2_4\n"); - printf("Test_TC_FAN_3_6\n"); - printf("Test_TC_CGEN_1_1\n"); - printf("Test_TC_CGEN_2_1\n"); - printf("Test_TC_DGGEN_1_1\n"); - printf("Test_TC_GRPKEY_1_1\n"); - printf("Test_TC_GRPKEY_2_2\n"); - printf("Test_TC_ICDM_1_1\n"); - printf("Test_TC_I_1_1\n"); - printf("Test_TC_I_2_1\n"); - printf("Test_TC_I_2_2\n"); - printf("Test_TC_I_2_3\n"); - printf("Test_TC_ILL_1_1\n"); - printf("Test_TC_ILL_2_1\n"); - printf("Test_TC_ILL_2_2\n"); - printf("Test_TC_LVL_1_1\n"); - printf("Test_TC_LVL_2_1\n"); - printf("Test_TC_LVL_2_2\n"); - printf("Test_TC_LVL_3_1\n"); - printf("Test_TC_LVL_4_1\n"); - printf("Test_TC_LVL_5_1\n"); - printf("Test_TC_LVL_6_1\n"); - printf("Test_TC_LVL_7_1\n"); - printf("Test_TC_LCFG_1_1\n"); - printf("Test_TC_LUNIT_1_2\n"); - printf("Test_TC_LUNIT_3_1\n"); - printf("Test_TC_LTIME_1_2\n"); - printf("Test_TC_LTIME_3_1\n"); - printf("Test_TC_LWM_1_1\n"); - printf("Test_TC_LWM_2_1\n"); - printf("Test_TC_WASHERCTRL_1_1\n"); - printf("Test_TC_WASHERCTRL_2_1\n"); - printf("Test_TC_WASHERCTRL_2_2\n"); - printf("Test_TC_OTCCM_1_1\n"); - printf("Test_TC_DRYERCTRL_1_1\n"); - printf("Test_TC_DRYERCTRL_2_1\n"); - printf("Test_TC_LOWPOWER_1_1\n"); - printf("Test_TC_KEYPADINPUT_1_2\n"); - printf("Test_TC_APPLAUNCHER_1_3\n"); - printf("Test_TC_MEDIAINPUT_1_4\n"); - printf("Test_TC_WAKEONLAN_1_5\n"); - printf("Test_TC_CHANNEL_1_6\n"); - printf("Test_TC_MEDIAPLAYBACK_1_7\n"); - printf("Test_TC_AUDIOOUTPUT_1_8\n"); - printf("Test_TC_TGTNAV_1_9\n"); - printf("Test_TC_APBSC_1_10\n"); - printf("Test_TC_CONTENTLAUNCHER_1_11\n"); - printf("Test_TC_ALOGIN_1_12\n"); - printf("Test_TC_LOWPOWER_2_1\n"); - printf("Test_TC_KEYPADINPUT_3_2\n"); - printf("Test_TC_KEYPADINPUT_3_3\n"); - printf("Test_TC_APPLAUNCHER_3_5\n"); - printf("Test_TC_APPLAUNCHER_3_6\n"); - printf("Test_TC_MEDIAINPUT_3_10\n"); - printf("Test_TC_MEDIAINPUT_3_11\n"); - printf("Test_TC_MEDIAINPUT_3_12\n"); - printf("Test_TC_MEDIAINPUT_3_13\n"); - printf("Test_TC_CHANNEL_5_1\n"); - printf("Test_TC_CHANNEL_5_2\n"); - printf("Test_TC_CHANNEL_5_3\n"); - printf("Test_TC_MEDIAPLAYBACK_6_1\n"); - printf("Test_TC_MEDIAPLAYBACK_6_2\n"); - printf("Test_TC_MEDIAPLAYBACK_6_3\n"); - printf("Test_TC_MEDIAPLAYBACK_6_4\n"); - printf("Test_TC_AUDIOOUTPUT_7_1\n"); - printf("Test_TC_AUDIOOUTPUT_7_2\n"); - printf("Test_TC_TGTNAV_8_1\n"); - printf("Test_TC_APBSC_9_1\n"); - printf("Test_TC_CONTENTLAUNCHER_10_1\n"); - printf("Test_TC_WAKEONLAN_4_1\n"); - printf("Test_TC_ALOGIN_12_1\n"); - printf("Test_TC_CONTENTLAUNCHER_10_3\n"); - printf("Test_TC_CONTENTLAUNCHER_10_5\n"); - printf("Test_TC_CONTENTLAUNCHER_10_7\n"); - printf("Test_TC_MOD_1_1\n"); - printf("OTA_SuccessfulTransfer\n"); - printf("Test_TC_OCC_1_1\n"); - printf("Test_TC_OCC_2_1\n"); - printf("Test_TC_OCC_2_3\n"); - printf("Test_TC_OO_1_1\n"); - printf("Test_TC_OO_2_1\n"); - printf("Test_TC_OO_2_2\n"); - printf("Test_TC_OO_2_4\n"); - printf("Test_TC_OPSTATE_1_1\n"); - printf("Test_TC_PS_1_1\n"); - printf("Test_TC_PS_2_1\n"); - printf("Test_TC_PRS_1_1\n"); - printf("Test_TC_PRS_2_1\n"); - printf("Test_TC_PRS_2_2\n"); - printf("Test_TC_PCC_1_1\n"); - printf("Test_TC_PCC_2_1\n"); - printf("Test_TC_PCC_2_2\n"); - printf("Test_TC_PCC_2_3\n"); - printf("Test_TC_PCC_2_4\n"); - printf("Test_TC_REFALM_1_1\n"); - printf("Test_TC_REFALM_2_1\n"); - printf("Test_TC_RH_1_1\n"); - printf("Test_TC_RVCCLEANM_1_1\n"); - printf("Test_TC_RVCRUNM_1_1\n"); - printf("Test_TC_RVCOPSTATE_1_1\n"); - printf("Test_TC_SMOKECO_1_1\n"); - printf("Test_TC_SMOKECO_2_1\n"); - printf("Test_TC_SWTCH_1_1\n"); - printf("Test_TC_TCCM_1_1\n"); - printf("Test_TC_TCTL_1_1\n"); - printf("Test_TC_TCTL_2_2\n"); - printf("Test_TC_TCTL_2_3\n"); - printf("Test_TC_TCTL_3_2\n"); - printf("Test_TC_TCTL_3_3\n"); - printf("Test_TC_TMP_1_1\n"); - printf("Test_TC_TMP_2_1\n"); - printf("Test_TC_TSTAT_1_1\n"); - printf("Test_TC_TSUIC_1_1\n"); - printf("Test_TC_TSUIC_2_1\n"); - printf("Test_TC_TSUIC_2_2\n"); - printf("Test_TC_DGTHREAD_1_1\n"); - printf("Test_TC_TIMESYNC_1_1\n"); - printf("Test_TC_TIMESYNC_2_3\n"); - printf("Test_TC_ULABEL_1_1\n"); - printf("Test_TC_ULABEL_2_1\n"); - printf("Test_TC_ULABEL_2_2\n"); - printf("Test_TC_ULABEL_2_3\n"); - printf("Test_TC_ULABEL_2_4\n"); - printf("Test_TC_DGWIFI_1_1\n"); - printf("Test_TC_DGWIFI_2_1\n"); - printf("Test_TC_DGWIFI_2_3\n"); - printf("Test_TC_WNCV_1_1\n"); - printf("Test_TC_WNCV_2_1\n"); - printf("Test_TC_WNCV_2_2\n"); - printf("Test_TC_WNCV_2_3\n"); - printf("Test_TC_WNCV_2_5\n"); - printf("Test_TC_WNCV_3_1\n"); - printf("Test_TC_WNCV_3_2\n"); - printf("Test_TC_WNCV_3_3\n"); - printf("Test_TC_WNCV_3_4\n"); - printf("Test_TC_WNCV_3_5\n"); - printf("Test_TC_WNCV_4_1\n"); - printf("Test_TC_WNCV_4_2\n"); - printf("Test_TC_WNCV_4_3\n"); - printf("Test_TC_WNCV_4_4\n"); - printf("Test_TC_WNCV_4_5\n"); - printf("TV_TargetNavigatorCluster\n"); - printf("TV_AudioOutputCluster\n"); - printf("TV_ApplicationLauncherCluster\n"); - printf("TV_KeypadInputCluster\n"); - printf("TV_AccountLoginCluster\n"); - printf("TV_WakeOnLanCluster\n"); - printf("TV_ApplicationBasicCluster\n"); - printf("TV_MediaPlaybackCluster\n"); - printf("TV_ChannelCluster\n"); - printf("TV_LowPowerCluster\n"); - printf("TV_ContentLauncherCluster\n"); - printf("TV_MediaInputCluster\n"); - printf("TestCASERecovery\n"); - printf("TestCluster\n"); - printf("TestConstraints\n"); - printf("TestDelayCommands\n"); - printf("TestLogCommands\n"); - printf("TestSaveAs\n"); - printf("TestConfigVariables\n"); - printf("TestDescriptorCluster\n"); - printf("TestFabricRemovalWhileSubscribed\n"); - printf("TestGeneralCommissioning\n"); - printf("TestIdentifyCluster\n"); - printf("TestOperationalCredentialsCluster\n"); - printf("TestModeSelectCluster\n"); - printf("TestTemperatureControl\n"); - printf("TestSelfFabricRemoval\n"); - printf("TestSystemCommands\n"); - printf("TestBinding\n"); - printf("TestUserLabelCluster\n"); - printf("TestUserLabelClusterConstraints\n"); - printf("TestArmFailSafe\n"); - printf("TestFanControl\n"); - printf("TestAccessControlConstraints\n"); - printf("TestLevelControlWithOnOffDependency\n"); - printf("TestCommissioningWindow\n"); - printf("TestCommissionerNodeId\n"); - printf("TestTimeSynchronization\n"); - printf("TestOperationalState\n"); - printf("TestRVCOperationalState\n"); - printf("TestDishwasherAlarm\n"); - printf("TestMultiAdmin\n"); - printf("Test_TC_DGSW_1_1\n"); - printf("TestSubscribe_OnOff\n"); - printf("TestSubscribe_AdministratorCommissioning\n"); - printf("DL_UsersAndCredentials\n"); - printf("DL_Schedules\n"); - printf("Test_TC_DRLK_1_1\n"); - printf("Test_TC_DRLK_2_4\n"); - printf("Test_TC_DRLK_2_5\n"); - printf("Test_TC_DRLK_2_6\n"); - printf("Test_TC_DRLK_2_7\n"); - printf("Test_TC_DRLK_2_8\n"); - printf("Test_TC_DRLK_2_11\n"); - printf("TestGroupsCluster\n"); - printf("Test_TC_G_1_1\n"); - printf("TestScenesFabricRemoval\n"); - printf("Test_TC_S_1_1\n"); - printf("Test_TC_S_2_1\n"); - printf("Test_TC_S_2_4\n"); - printf("TestActivatedCarbonFilterMonitoring\n"); - printf("TestHepaFilterMonitoring\n"); - printf("Test_TC_ACFREMON_1_1\n"); - printf("Test_TC_ACFREMON_2_1\n"); - printf("Test_TC_HEPAFREMON_1_1\n"); - printf("Test_TC_HEPAFREMON_2_1\n"); - - return CHIP_NO_ERROR; - } -}; - -class ManualTestList : public Command { -public: - ManualTestList() - : Command("list-manual") {}; - CHIP_ERROR Run() override - { - - return CHIP_NO_ERROR; - } -}; - -class TestAccessControlCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestAccessControlCluster() - : TestCommandBridge("TestAccessControlCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestAccessControlCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestAccessControlCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); - err = TestWaitForCommissionee_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write entries\n"); - err = TestWriteEntries_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify\n"); - err = TestVerify_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write entries empty lists\n"); - err = TestWriteEntriesEmptyLists_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify\n"); - err = TestVerify_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write entry invalid privilege\n"); - err = TestWriteEntryInvalidPrivilege_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify\n"); - err = TestVerify_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write entry invalid auth mode\n"); - err = TestWriteEntryInvalidAuthMode_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify\n"); - err = TestVerify_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write entry invalid subject\n"); - err = TestWriteEntryInvalidSubject_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify\n"); - err = TestVerify_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Write entry invalid target\n"); - err = TestWriteEntryInvalidTarget_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify\n"); - err = TestVerify_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write entry too many subjects\n"); - err = TestWriteEntryTooManySubjects_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Verify\n"); - err = TestVerify_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write entry too many targets\n"); - err = TestWriteEntryTooManyTargets_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify\n"); - err = TestVerify_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write too many entries\n"); - err = TestWriteTooManyEntries_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify\n"); - err = TestVerify_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Restore ACL\n"); - err = TestRestoreAcl_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Verify\n"); - err = TestVerify_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Validate resource minima (SubjectsPerAccessControlEntry)\n"); - err = TestValidateResourceMinimaSubjectsPerAccessControlEntry_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Validate resource minima (TargetsPerAccessControlEntry)\n"); - err = TestValidateResourceMinimaTargetsPerAccessControlEntry_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Validate resource minima (AccessControlEntriesPerFabric)\n"); - err = TestValidateResourceMinimaAccessControlEntriesPerFabric_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForCommissionee_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteEntries_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:1UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:2UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:9UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:10UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:17UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:18UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:21ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:22ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:23ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:24U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:25UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:26UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:27U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entries: Error: %@", err); - } else { - NSLog(@"Write entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntriesEmptyLists_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entries empty lists: Error: %@", err); - } else { - NSLog(@"Write entries empty lists: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidPrivilege_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid privilege: Error: %@", err); - } else { - NSLog(@"Write entry invalid privilege: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidAuthMode_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid auth mode: Error: %@", err); - } else { - NSLog(@"Write entry invalid auth mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidSubject_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid subject: Error: %@", err); - } else { - NSLog(@"Write entry invalid subject: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidTarget_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid target: Error: %@", err); - } else { - NSLog(@"Write entry invalid target: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryTooManySubjects_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:1ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:2ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:3ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[4] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[5] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[6] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - temp_3[7] = - [NSNumber numberWithUnsignedLongLong:8ULL]; - temp_3[8] = - [NSNumber numberWithUnsignedLongLong:9ULL]; - temp_3[9] = - [NSNumber numberWithUnsignedLongLong:10ULL]; - temp_3[10] = - [NSNumber numberWithUnsignedLongLong:11ULL]; - temp_3[11] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[12] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[13] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[14] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - temp_3[15] = - [NSNumber numberWithUnsignedLongLong:16ULL]; - temp_3[16] = - [NSNumber numberWithUnsignedLongLong:17ULL]; - temp_3[17] = - [NSNumber numberWithUnsignedLongLong:18ULL]; - temp_3[18] = - [NSNumber numberWithUnsignedLongLong:19ULL]; - temp_3[19] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry too many subjects: Error: %@", err); - } else { - NSLog(@"Write entry too many subjects: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryTooManyTargets_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = - [NSNumber numberWithUnsignedShort:2U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - temp_3[3] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).endpoint = - [NSNumber numberWithUnsignedShort:4U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).deviceType = nil; - - temp_3[4] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).endpoint = - [NSNumber numberWithUnsignedShort:5U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).deviceType = nil; - - temp_3[5] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).endpoint = - [NSNumber numberWithUnsignedShort:6U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).deviceType = nil; - - temp_3[6] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).endpoint = - [NSNumber numberWithUnsignedShort:7U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).deviceType = nil; - - temp_3[7] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).deviceType = nil; - - temp_3[8] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).endpoint = - [NSNumber numberWithUnsignedShort:9U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).deviceType = nil; - - temp_3[9] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).endpoint = - [NSNumber numberWithUnsignedShort:10U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).deviceType = nil; - - temp_3[10] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).deviceType = nil; - - temp_3[11] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).endpoint = - [NSNumber numberWithUnsignedShort:12U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).deviceType = nil; - - temp_3[12] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).endpoint = - [NSNumber numberWithUnsignedShort:13U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).deviceType = nil; - - temp_3[13] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).endpoint = - [NSNumber numberWithUnsignedShort:14U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).deviceType = nil; - - temp_3[14] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).endpoint = - [NSNumber numberWithUnsignedShort:15U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).deviceType = nil; - - temp_3[15] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).deviceType = nil; - - temp_3[16] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).endpoint = - [NSNumber numberWithUnsignedShort:17U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).deviceType = nil; - - temp_3[17] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).endpoint = - [NSNumber numberWithUnsignedShort:18U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).deviceType = nil; - - temp_3[18] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).deviceType = nil; - - temp_3[19] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).endpoint = - [NSNumber numberWithUnsignedShort:20U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry too many targets: Error: %@", err); - } else { - NSLog(@"Write entry too many targets: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTooManyEntries_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:1UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:2UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:9UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:10UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:17UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:18UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:21ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:22ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:23ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:24U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:25UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:26UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:27U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[4] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:28ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:29ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:30ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:31ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:32U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:33UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:34UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:35U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write too many entries: Error: %@", err); - } else { - NSLog(@"Write too many entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreAcl_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore ACL: Error: %@", err); - } else { - NSLog(@"Restore ACL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaSubjectsPerAccessControlEntry_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Error: %@", err); - } else { - NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaTargetsPerAccessControlEntry_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Error: %@", err); - } else { - NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaAccessControlEntriesPerFabric_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Error: %@", err); - } else { - NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_1_1() - : TestCommandBridge("Test_TC_ACL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); - err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute (Extension) in AttributeList\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_2_1() - : TestCommandBridge("Test_TC_ACL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH1 reads DUT Endpoint 0 AccessControl cluster SubjectsPerAccessControlEntry attribute\n"); - if (ShouldSkip("ACL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2Th1ReadsDutEndpoint0AccessControlClusterSubjectsPerAccessControlEntryAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster TargetsPerAccessControlEntry attribute\n"); - if (ShouldSkip("ACL.S.A0003")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsDutEndpoint0AccessControlClusterTargetsPerAccessControlEntryAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH1 reads DUT Endpoint 0 AccessControl cluster AccessControlEntriesPerFabric attribute\n"); - if (ShouldSkip("ACL.S.A0004")) { - NextTest(); - return; - } - err = TestStep4Th1ReadsDutEndpoint0AccessControlClusterAccessControlEntriesPerFabricAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2Th1ReadsDutEndpoint0AccessControlClusterSubjectsPerAccessControlEntryAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 AccessControl cluster SubjectsPerAccessControlEntry attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 AccessControl cluster SubjectsPerAccessControlEntry attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("subjectsPerAccessControlEntry", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsDutEndpoint0AccessControlClusterTargetsPerAccessControlEntryAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster TargetsPerAccessControlEntry attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster TargetsPerAccessControlEntry attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("targetsPerAccessControlEntry", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); - VerifyOrReturn(CheckConstraintMaxValue("targetsPerAccessControlEntry", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1ReadsDutEndpoint0AccessControlClusterAccessControlEntriesPerFabricAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 reads DUT Endpoint 0 AccessControl cluster AccessControlEntriesPerFabric attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 reads DUT Endpoint 0 AccessControl cluster AccessControlEntriesPerFabric attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("accessControlEntriesPerFabric", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("accessControlEntriesPerFabric", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_2_3() - : TestCommandBridge("Test_TC_ACL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("D_OK_EMPTY", &mDOkEmpty); - AddArgument("D_OK_SINGLE", &mDOkSingle); - AddArgument("D_OK_FULL", &mDOkFull); - AddArgument("D_BAD_LENGTH", &mDBadLength); - AddArgument("D_BAD_STRUCT", &mDBadStruct); - AddArgument("D_BAD_LIST", &mDBadList); - AddArgument("D_BAD_ELEM", &mDBadElem); - AddArgument("D_BAD_OVERFLOW", &mDBadOverflow); - AddArgument("D_BAD_UNDERFLOW", &mDBadUnderflow); - AddArgument("D_BAD_NONE", &mDBadNone); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute\n"); - err = TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDOkEmpty; - chip::Optional mDOkSingle; - chip::Optional mDOkFull; - chip::Optional mDBadLength; - chip::Optional mDBadStruct; - chip::Optional mDBadList; - chip::Optional mDBadElem; - chip::Optional mDBadOverflow; - chip::Optional mDBadUnderflow; - chip::Optional mDBadNone; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull CurrentFabricIndexValue; - - CHIP_ERROR TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - CurrentFabricIndexValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Error: %@", err); - } else { - NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadLength.HasValue() ? [NSData dataWithBytes:mDBadLength.Value().data() length:mDBadLength.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x32\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:129]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Error: %@", err); - } else { - NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadStruct.HasValue() ? [NSData dataWithBytes:mDBadStruct.Value().data() length:mDBadStruct.Value().size()] : [[NSData alloc] initWithBytes:"\x15\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Error: %@", err); - } else { - NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadList.HasValue() ? [NSData dataWithBytes:mDBadList.Value().data() length:mDBadList.Value().size()] : [[NSData alloc] initWithBytes:"\x37\x01\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:72]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadElem.HasValue() ? [NSData dataWithBytes:mDBadElem.Value().data() length:mDBadElem.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x10\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:65]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadOverflow.HasValue() ? [NSData dataWithBytes:mDBadOverflow.Value().data() length:mDBadOverflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18\xFF" length:72]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Error: %@", err); - } else { - NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadUnderflow.HasValue() ? [NSData dataWithBytes:mDBadUnderflow.Value().data() length:mDBadUnderflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00" length:70]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Error: %@", err); - } else { - NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadNone.HasValue() ? [NSData dataWithBytes:mDBadNone.Value().data() length:mDBadNone.Value().size()] : [[NSData alloc] initWithBytes:"" length:0]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Error: %@", err); - } else { - NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Error: %@", err); - } else { - NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACE_1_1() - : TestCommandBridge("Test_TC_ACE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read the commissioner node ID\n"); - err = TestReadTheCommissionerNodeId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]\n"); - err = TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege)\n"); - err = TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.\n"); - err = TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13a: Write NodeLabel attribute (Basic - requires manage)\n"); - err = TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 13b: Send TestEventTrigger (General Diagnostics - requires manage)\n"); - err = TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 13c: Tead the VendorID attribute (Basic - requires view)\n"); - err = TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) \n"); - err = TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) \n"); - err = TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 22: Tead the VendorID attribute (Basic - requires view)\n"); - err = TestStep22TeadTheVendorIDAttributeBasicRequiresView_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]\n"); - err = TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) \n"); - err = TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); - err = TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 38; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull commissionerNodeId; - - CHIP_ERROR TestReadTheCommissionerNodeId_1() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeId = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("NOCs", value, 1)); - VerifyOrReturn(CheckConstraintMaxLength("NOCs", value, 1)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Error: %@", err); - } else { - NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Error: %@", err); - } else { - NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Error: %@", err); - } else { - NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Error: %@", err); - } else { - NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Error: %@", err); - } else { - NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22TeadTheVendorIDAttributeBasicRequiresView_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Error: %@", err); - } else { - NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Error: %@", err); - } else { - NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); - } else { - NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACE_1_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACE_1_5() - : TestCommandBridge("Test_TC_ACE_1_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); - AddArgument("PakeVerifier", &mPakeVerifier); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACE_1_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); - err = TestTh1ReadsTheFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2 & 3: TH1 puts DUT into commissioning mode, TH2 commissions DUT using admin node ID N2\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH1 opens the commissioning window on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep2Th1OpensTheCommissioningWindowOnTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Waiting after opening commissioning window\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitingAfterOpeningCommissioningWindow_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH2 commissions DUT using admin node ID N2\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for TH2\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH2 reads the fabric index\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4Th2ReadsTheFabricIndex_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the commissioner node ID from the alpha fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]\n"); - err = TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the commissioner node ID from the beta fabric\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestReadTheCommissionerNodeIdFromTheBetaFabric_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH2 writes ACL giving view privilge for basic cluster\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); - err = TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); - err = TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH2 reads descriptor cluster - expect UNSUPPORTED_ACCESS\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute - expect SUCCESS\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); - err = TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric commandto the DUT with the FabricIndex set to th2FabricIndex\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mDiscriminator; - chip::Optional mWaitAfterCommissioning; - chip::Optional mPakeVerifier; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th1FabricIndex; - - CHIP_ERROR TestTh1ReadsTheFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH1 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th1FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2Th1OpensTheCommissioningWindowOnTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; - params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; - params.iterations = - [NSNumber numberWithUnsignedInt:1000UL]; - params.salt = - [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; - [cluster openCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - NSNumber * _Nonnull th2FabricIndex; - - CHIP_ERROR TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th2FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th2ReadsTheFabricIndex_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull commissionerNodeIdAlpha; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_9() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [th1FabricIndex copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:29UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [th1FabricIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdBeta; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_11() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdBeta copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [th2FabricIndex copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:40UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [th2FabricIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); - } else { - NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [th2FabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Error: %@", err); - } else { - NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_AIRQUAL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AIRQUAL_1_1() - : TestCommandBridge("Test_TC_AIRQUAL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AIRQUAL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!AIRQUAL.S.F00 && !AIRQUAL.S.F01 && !AIRQUAL.S.F02 && !AIRQUAL.S.F03")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AIRQUAL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AIRQUAL_2_1() - : TestCommandBridge("Test_TC_AIRQUAL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AIRQUAL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the AirQuality attribute.\n"); - if (ShouldSkip("AIRQUAL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheAirQualityAttribute_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheAirQualityAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirQualityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("airQuality", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("airQuality", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("airQuality", [value unsignedCharValue], 6U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BOOL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BOOL_1_1() - : TestCommandBridge("Test_TC_BOOL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BOOL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("BOOL.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip(" !BOOL.S.E00 && PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BOOL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BOOL_2_1() - : TestCommandBridge("Test_TC_BOOL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BOOL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the StateValue attribute from the DUT\n"); - if (ShouldSkip("BOOL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheStateValueAttributeFromTheDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheStateValueAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("stateValue", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BRBINFO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BRBINFO_1_1() - : TestCommandBridge("Test_TC_BRBINFO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BRBINFO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BRBINFO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BRBINFO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(VendorName) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(VendorID) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductName) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0003")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(NodeLabel) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0005")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0007")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0008")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0009")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000a")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4k: TH reads optional attribute(PartNumber) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4l: TH reads optional attribute(ProductURL) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000d")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4m: TH reads optional attribute(ProductLabel) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000e")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4n: TH reads optional attribute(SerialNumber) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000f")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4o: TH reads optional attribute(UniqueID) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0012")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4p: TH reads optional attribute(ProductAppearance) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0014")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeProductAppearanceInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5b: TH reads optional event(StartUp) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5c: TH reads optional attribute(ShutDown) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5d TH reads optional attribute(Leave) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 6: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 7: TH1 reads GeneratedCommandList from DUT\n"); - err = TestStep7Th1ReadsGeneratedCommandListFromDut_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeProductAppearanceInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(ProductAppearance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(ProductAppearance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsGeneratedCommandListFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACT_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACT_1_1() - : TestCommandBridge("Test_TC_ACT_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACT_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACT_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACT_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Read the optional attribute(SetupURL) in AttributeList\n"); - if (ShouldSkip("ACT.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6a: TH Read the optional command (InstantAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadTheOptionalCommandInstantActionInAcceptedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6b: TH Read the optional command (InstantActionWithTransition) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadTheOptionalCommandInstantActionWithTransitionInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6C: TH Read the optional command (StartAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadTheOptionalCommandStartActionInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6d: TH Read the optional command (StartActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadTheOptionalCommandStartActionWithDurationInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6e: TH Read the optional command (StopAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThReadTheOptionalCommandStopActionInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6f: TH Read the optional command (PauseAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThReadTheOptionalCommandPauseActionInAcceptedCommandList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6g: TH Read the optional command (PauseActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadTheOptionalCommandPauseActionWithDurationInAcceptedCommandList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6h: TH Read the optional command (ResumeAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6hThReadTheOptionalCommandResumeActionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6i: TH Read the optional command (EnableAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThReadTheOptionalCommandEnableActionInAcceptedCommandList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6j: TH Read the optional command (EnableActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep6jThReadTheOptionalCommandEnableActionWithDurationInAcceptedCommandList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6k: TH Read the optional command (DisableAction) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThReadTheOptionalCommandDisableActionInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6l: TH Read the optional command (DisableActionWithDuration) in AcceptedCommandList\n"); - if (ShouldSkip("ACT.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep6lThReadTheOptionalCommandDisableActionWithDurationInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadTheOptionalCommandInstantActionInAcceptedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH Read the optional command (InstantAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH Read the optional command (InstantAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadTheOptionalCommandInstantActionWithTransitionInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH Read the optional command (InstantActionWithTransition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH Read the optional command (InstantActionWithTransition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadTheOptionalCommandStartActionInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6C: TH Read the optional command (StartAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6C: TH Read the optional command (StartAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadTheOptionalCommandStartActionWithDurationInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH Read the optional command (StartActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH Read the optional command (StartActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadTheOptionalCommandStopActionInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH Read the optional command (StopAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH Read the optional command (StopAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadTheOptionalCommandPauseActionInAcceptedCommandList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH Read the optional command (PauseAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH Read the optional command (PauseAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadTheOptionalCommandPauseActionWithDurationInAcceptedCommandList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH Read the optional command (PauseActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH Read the optional command (PauseActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadTheOptionalCommandResumeActionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH Read the optional command (ResumeAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6h: TH Read the optional command (ResumeAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThReadTheOptionalCommandEnableActionInAcceptedCommandList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH Read the optional command (EnableAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6i: TH Read the optional command (EnableAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadTheOptionalCommandEnableActionWithDurationInAcceptedCommandList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH Read the optional command (EnableActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6j: TH Read the optional command (EnableActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThReadTheOptionalCommandDisableActionInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH Read the optional command (DisableAction) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6k: TH Read the optional command (DisableAction) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadTheOptionalCommandDisableActionWithDurationInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH Read the optional command (DisableActionWithDuration) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6l: TH Read the optional command (DisableActionWithDuration) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BIND_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BIND_1_1() - : TestCommandBridge("Test_TC_BIND_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BIND_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BIND_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BIND_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_1_1() - : TestCommandBridge("Test_TC_CC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - if (ShouldSkip("( !CC.S.F00 && !CC.S.F01 && !CC.S.F02 && !CC.S.F03 && !CC.S.F04 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList\n"); - if (ShouldSkip("CC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList\n"); - if (ShouldSkip("CC.S.A0005")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4h: TH reads the optional attribute(CompensationText) in AttributeList\n"); - if (ShouldSkip("CC.S.A0006")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4j: TH reads the Primary1X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4jThReadsThePrimary1XAttributeInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4k: TH reads the Primary1Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4kThReadsThePrimary1YAttributeInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4l: TH reads the Primary1Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0013")) { - NextTest(); - return; - } - err = TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4m: TH reads the Primary2X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4mThReadsThePrimary2XAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4n: TH reads the Primary2Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0016")) { - NextTest(); - return; - } - err = TestStep4nThReadsThePrimary2YAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4o: TH reads the Primary2Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0017")) { - NextTest(); - return; - } - err = TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4p: TH reads the Primary3X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0019")) { - NextTest(); - return; - } - err = TestStep4pThReadsThePrimary3XAttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4q: TH reads the Primary3Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A001a")) { - NextTest(); - return; - } - err = TestStep4qThReadsThePrimary3YAttributeInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4r: TH reads the Primary3Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A001b")) { - NextTest(); - return; - } - err = TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4s: TH reads the Primary4X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4sThReadsThePrimary4XAttributeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4t: TH reads the Primary4Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4tThReadsThePrimary4YAttributeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4u: TH reads the Primary4Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0022")) { - NextTest(); - return; - } - err = TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4v: TH reads the Primary5X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0024")) { - NextTest(); - return; - } - err = TestStep4vThReadsThePrimary5XAttributeInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4w: TH reads the Primary5Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0025")) { - NextTest(); - return; - } - err = TestStep4wThReadsThePrimary5YAttributeInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: TH reads the Primary5Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0026")) { - NextTest(); - return; - } - err = TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4y: TH reads the Primary6X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0028")) { - NextTest(); - return; - } - err = TestStep4yThReadsThePrimary6XAttributeInAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: TH reads the Primary6Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0029")) { - NextTest(); - return; - } - err = TestStep4zThReadsThePrimary6YAttributeInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4a1: TH reads the Primary6Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A002a")) { - NextTest(); - return; - } - err = TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0030")) { - NextTest(); - return; - } - err = TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0031")) { - NextTest(); - return; - } - err = TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0032")) { - NextTest(); - return; - } - err = TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0033")) { - NextTest(); - return; - } - err = TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A0034")) { - NextTest(); - return; - } - err = TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0036")) { - NextTest(); - return; - } - err = TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0037")) { - NextTest(); - return; - } - err = TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A0038")) { - NextTest(); - return; - } - err = TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList\n"); - if (ShouldSkip("CC.S.A003a")) { - NextTest(); - return; - } - err = TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList\n"); - if (ShouldSkip("CC.S.A003b")) { - NextTest(); - return; - } - err = TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A003c")) { - NextTest(); - return; - } - err = TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4002")) { - NextTest(); - return; - } - err = TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4003")) { - NextTest(); - return; - } - err = TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4004")) { - NextTest(); - return; - } - err = TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4005")) { - NextTest(); - return; - } - err = TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4006")) { - NextTest(); - return; - } - err = TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400d")) { - NextTest(); - return; - } - err = TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.C44.Rsp")) { - NextTest(); - return; - } - err = TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.F03 && CC.S.F04 && CC.S.C47.Rsp")) { - NextTest(); - return; - } - err = TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C4b.Rsp")) { - NextTest(); - return; - } - err = TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C4c.Rsp")) { - NextTest(); - return; - } - err = TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 78; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsThePrimary1XAttributeInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsThePrimary1YAttributeInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsThePrimary2XAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsThePrimary2YAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsThePrimary3XAttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsThePrimary3YAttributeInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsThePrimary4XAttributeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsThePrimary4YAttributeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4vThReadsThePrimary5XAttributeInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4wThReadsThePrimary5YAttributeInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4yThReadsThePrimary6XAttributeInAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4zThReadsThePrimary6YAttributeInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16388UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16389UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16390UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16395UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16396UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16397UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16400UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 67UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 68UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 71UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 75UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 76UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_2_1() - : TestCommandBridge("Test_TC_CC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute\n"); - if (ShouldSkip("CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute\n"); - if (ShouldSkip("CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute\n"); - if (ShouldSkip("CC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0003) CurrentX attribute\n"); - if (ShouldSkip("CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0004) CurrentY attribute\n"); - if (ShouldSkip("CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute\n"); - if (ShouldSkip("CC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0006) CompensationText attribute\n"); - if (ShouldSkip("CC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0008) ColorMode attribute\n"); - if (ShouldSkip("CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the (0x000f) Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute\n"); - if (ShouldSkip("CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute\n"); - if (ShouldSkip("CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute\n"); - if (ShouldSkip("CC.S.A4002")) { - NextTest(); - return; - } - err = TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute\n"); - if (ShouldSkip("CC.S.A4003")) { - NextTest(); - return; - } - err = TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute\n"); - if (ShouldSkip("CC.S.A4004")) { - NextTest(); - return; - } - err = TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute\n"); - if (ShouldSkip("CC.S.A4005")) { - NextTest(); - return; - } - err = TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT\n"); - if (ShouldSkip("CC.S.A4006")) { - NextTest(); - return; - } - err = TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT\n"); - err = TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute\n"); - if (ShouldSkip("CC.S.A400a")) { - NextTest(); - return; - } - err = TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute\n"); - if (ShouldSkip("CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute\n"); - if (ShouldSkip("CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute\n"); - if (ShouldSkip("CC.S.A400d")) { - NextTest(); - return; - } - err = TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute\n"); - if (ShouldSkip("CC.S.A0010")) { - NextTest(); - return; - } - err = TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 25: TH reads Primary1X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0011")) { - NextTest(); - return; - } - err = TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 26: TH reads Primary1Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0012")) { - NextTest(); - return; - } - err = TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 27: TH reads Primary1Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0013")) { - NextTest(); - return; - } - err = TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 28: TH reads Primary2X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0015")) { - NextTest(); - return; - } - err = TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 29: TH reads Primary2Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0016")) { - NextTest(); - return; - } - err = TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 30: TH reads Primary2Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0017")) { - NextTest(); - return; - } - err = TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 31: TH reads Primary3X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0019")) { - NextTest(); - return; - } - err = TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 32: TH reads Primary3Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001a")) { - NextTest(); - return; - } - err = TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 33: TH reads Primary3Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001b")) { - NextTest(); - return; - } - err = TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 34: TH reads Primary4X attribute from DUT Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0020")) { - NextTest(); - return; - } - err = TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 35: TH reads Primary4Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0021")) { - NextTest(); - return; - } - err = TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 36: TH reads Primary4Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0022")) { - NextTest(); - return; - } - err = TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 37: TH reads Primary5X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0024")) { - NextTest(); - return; - } - err = TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 38: TH reads Primary5Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0025")) { - NextTest(); - return; - } - err = TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 39: TH reads Primary5Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0026")) { - NextTest(); - return; - } - err = TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 40: TH reads Primary6X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0028")) { - NextTest(); - return; - } - err = TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 41: TH reads Primary6Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0029")) { - NextTest(); - return; - } - err = TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 42: TH reads Primary6Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A002a")) { - NextTest(); - return; - } - err = TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute\n"); - if (ShouldSkip("CC.S.A0030")) { - NextTest(); - return; - } - err = TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute\n"); - if (ShouldSkip("CC.S.A0031")) { - NextTest(); - return; - } - err = TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute\n"); - if (ShouldSkip("CC.S.A0032")) { - NextTest(); - return; - } - err = TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute\n"); - if (ShouldSkip("CC.S.A0033")) { - NextTest(); - return; - } - err = TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute\n"); - if (ShouldSkip("CC.S.A0034")) { - NextTest(); - return; - } - err = TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute\n"); - if (ShouldSkip("CC.S.A0036")) { - NextTest(); - return; - } - err = TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute\n"); - if (ShouldSkip("CC.S.A0037")) { - NextTest(); - return; - } - err = TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute\n"); - if (ShouldSkip("CC.S.A0038")) { - NextTest(); - return; - } - err = TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute\n"); - if (ShouldSkip("CC.S.A003a")) { - NextTest(); - return; - } - err = TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute\n"); - if (ShouldSkip("CC.S.A003b")) { - NextTest(); - return; - } - err = TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute\n"); - if (ShouldSkip("CC.S.A003c")) { - NextTest(); - return; - } - err = TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 54; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentHue", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65534U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDriftCompensationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("driftCompensation", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("driftCompensation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("driftCompensation", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCompensationTextWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("compensationText", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("compensationText", value, 254)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("options", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("options", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedColorMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Error: %@", err); - } else { - NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopActive", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopActive", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopActive", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopDirection", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopDirection", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Error: %@", err); - } else { - NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Error: %@", err); - } else { - NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopStartEnhancedHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Error: %@", err); - } else { - NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopStoredEnhancedHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull FeatureMapValue; - - CHIP_ERROR TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - FeatureMapValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorCapabilitiesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Error: %@", err); - } else { - NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorCapabilities", actualValue, FeatureMapValue)); - } - - VerifyOrReturn(CheckConstraintType("colorCapabilities", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("colorCapabilities", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorCapabilities", [value unsignedShortValue], 31U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCoupleColorTempToLevelMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("coupleColorTempToLevelMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfPrimariesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Error: %@", err); - } else { - NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("numberOfPrimaries", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfPrimaries", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfPrimaries", [value unsignedCharValue], 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWhitePointXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Error: %@", err); - } else { - NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("whitePointX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("whitePointX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("whitePointX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWhitePointYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Error: %@", err); - } else { - NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("whitePointY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("whitePointY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("whitePointY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Error: %@", err); - } else { - NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointRX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Error: %@", err); - } else { - NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointRY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointRIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Error: %@", err); - } else { - NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointGX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Error: %@", err); - } else { - NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointGY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointGIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Error: %@", err); - } else { - NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointBX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Error: %@", err); - } else { - NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointBY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointBIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_3_2() - : TestCommandBridge("Test_TC_CC_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2fThReadsCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2gThReadsCurrentHueAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3fThReadsCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3gThReadsCurrentHueAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 22U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 68U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 79U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 111U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2gThReadsCurrentHueAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 79U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 111U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:60U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:3U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 16U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 183U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 247U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3gThReadsCurrentHueAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_3_3() - : TestCommandBridge("Test_TC_CC_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentHueAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 195U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentHueAttributeFromDut_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:50U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 17U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_1() - : TestCommandBridge("Test_TC_CC_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SaturationConfigValue", 0, UINT8_MAX, &mSaturationConfigValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2fThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep3aThReadsColorModeAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSaturationConfigValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 80U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 115U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_2() - : TestCommandBridge("Test_TC_CC_4_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentSaturationAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsCurrentSaturationAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentSaturationAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4f: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentSaturationAttributeFromDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep5aThReadsColorModeAttributeFromDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 34; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:3U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 59U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 81U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 5U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 10U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsCurrentSaturationAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsCurrentSaturationAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_28() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4fThReadsCurrentSaturationAttributeFromDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_3() - : TestCommandBridge("Test_TC_CC_4_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2gThReadsCurrentSaturationAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: H reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cHReadsCurrentSaturationAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentSaturationAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3gThReadsCurrentSaturationAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: H reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bHReadsEnhancedColorModeAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:40U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 187U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 253U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:20U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:100U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Error: %@", err); - } else { - NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2gThReadsCurrentSaturationAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:40U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cHReadsCurrentSaturationAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 25U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:20U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:100U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Error: %@", err); - } else { - NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3gThReadsCurrentSaturationAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bHReadsEnhancedColorModeAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_4() - : TestCommandBridge("Test_TC_CC_4_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentHue attribute from DUT.\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentHueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentHueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:160U]; - params.saturation = - [NSNumber numberWithUnsignedChar:80U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 160U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_1() - : TestCommandBridge("Test_TC_CC_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentXAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep2b1ThReadsCurrentYAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentXAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentYAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentXAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentYAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep4aThWrites0ToTheOptionsAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH read Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep4bThReadOptionsAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThSendsOnCommandToDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4e: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentXAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentYAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThSendsOffCommandToDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4h: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsCurrentXAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4h: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsCurrentYAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4j: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4jThReadsCurrentXAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4j: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4jThReadsCurrentYAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4i: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsCurrentXAttributeFromDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4i: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsCurrentYAttributeFromDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5a: TH writes 1 to the Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep5aThWrites1ToTheOptionsAttribute_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5b: TH read Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep5bThReadOptionsAttribute_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsOnCommandToDut_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5e: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentXAttributeFromDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5e: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentYAttributeFromDut_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5fThSendsOffCommandToDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 5h: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentXAttributeFromDut_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 5h: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentYAttributeFromDut_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 5j: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentXAttributeFromDut_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 5j: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentYAttributeFromDut_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 5l: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentXAttributeFromDut_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 5l: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentYAttributeFromDut_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 6a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep6aThReadsColorModeAttributeFromDut_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 61; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2b1ThReadsCurrentYAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13107U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 32768U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 13107U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 19660U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrites0ToTheOptionsAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadOptionsAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH read Options attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH read Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsOnCommandToDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eThReadsCurrentXAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsCurrentYAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThSendsOffCommandToDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4hThReadsCurrentXAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsCurrentYAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4jThReadsCurrentXAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsCurrentYAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:26214U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_34() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4iThReadsCurrentXAttributeFromDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsCurrentYAttributeFromDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrites1ToTheOptionsAttribute_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes 1 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes 1 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadOptionsAttribute_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH read Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5b: TH read Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsOnCommandToDut_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_41() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5eThReadsCurrentXAttributeFromDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eThReadsCurrentYAttributeFromDut_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5fThSendsOffCommandToDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_46() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5hThReadsCurrentXAttributeFromDut_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5hThReadsCurrentYAttributeFromDut_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_50() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5jThReadsCurrentXAttributeFromDut_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 13107U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5jThReadsCurrentYAttributeFromDut_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 13107U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:26214U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_54() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5lThReadsCurrentXAttributeFromDut_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5lThReadsCurrentYAttributeFromDut_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_2() - : TestCommandBridge("Test_TC_CC_5_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends MoveColor command to DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveColorCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentXAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentYAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentXAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentYAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentXAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentYAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends StopMoveStep command to DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C47.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsStopMoveStepCommandToDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:33000U]; - params.colorY = - [NSNumber numberWithUnsignedShort:26000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsMoveColorCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveColorParams alloc] init]; - params.rateX = - [NSNumber numberWithShort:-100]; - params.rateY = - [NSNumber numberWithShort:100]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveColor command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveColor command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27200U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 36800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsCurrentYAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 22900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 31100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentXAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 26350U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 35650U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsCurrentYAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 23800U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 32200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull CurrentXValue; - - CHIP_ERROR TestStep2dThReadsCurrentXAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); - { - CurrentXValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CurrentYValue; - - CHIP_ERROR TestStep2dThReadsCurrentYAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); - { - CurrentYValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsStopMoveStepCommandToDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStopMoveStepParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopMoveStepWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_3() - : TestCommandBridge("Test_TC_CC_5_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentXAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentYAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentXAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentYAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:33000U]; - params.colorY = - [NSNumber numberWithUnsignedShort:20000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepColorParams alloc] init]; - params.stepX = - [NSNumber numberWithShort:-20000]; - params.stepY = - [NSNumber numberWithShort:-6000]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13000U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 33000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 14000U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 20000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_6_1() - : TestCommandBridge("Test_TC_CC_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait100ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 5s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait5s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2f: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep3aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait to turn Off light\n"); - err = TestWaitToTurnOffLight_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mConfigWait; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorTempPhysicalMinMiredsValue; - - CHIP_ERROR TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - { - ColorTempPhysicalMinMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorTempPhysicalMaxMiredsValue; - - CHIP_ERROR TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - { - ColorTempPhysicalMaxMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMinMiredsValue)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMaxMiredsValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; - params.colorTemperatureMireds = - [NSNumber numberWithUnsignedShort:310U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; - params.colorTemperatureMireds = - [NSNumber numberWithUnsignedShort:250U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 246U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 334U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 230U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 310U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitToTurnOffLight_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_6_5() - : TestCommandBridge("Test_TC_CC_6_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_6_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH writes to StartUpColorTemperatureMireds attribute with value StartUpColorTemperatureMireds\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: Verify that the DUT response contains StartUpColorTemperatureMireds that matches the StartUpColorTemperatureMireds set in Step 2a\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3aRebootTargetDevice_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3bRebootTargetDeviceDUT_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep5aThReadsColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait to turn Off light\n"); - err = TestWaitToTurnOffLight_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mConfigWait; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nullable StartUpColorTemperatureMiredsValue; - - CHIP_ERROR TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - { - StartUpColorTemperatureMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aRebootTargetDevice_10() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep3bRebootTargetDeviceDUT_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (StartUpColorTemperatureMiredsValue == nil) { - VerifyOrReturn(CheckValueNull("StartUpColorTemperatureMireds", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("StartUpColorTemperatureMireds", actualValue)); - VerifyOrReturn(CheckValue("StartUpColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitToTurnOffLight_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_7_3() - : TestCommandBridge("Test_TC_CC_7_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_7_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep6aThReadsColorModeAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 29; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:6000U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedShort:6000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedStepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:12000U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedShort:6000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedStepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_7_4() - : TestCommandBridge("Test_TC_CC_7_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_7_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestThReadsCurrentSaturationAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentSaturationAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:20000U]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 17000U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 23000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThReadsCurrentSaturationAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16000U]; - params.saturation = - [NSNumber numberWithUnsignedChar:80U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 16000U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 20000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentSaturationAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 13600U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 18400U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 80U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestColorControl_9_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestColorControl_9_1() - : TestCommandBridge("TestColorControl_9_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestColorControl_9_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); - err = TestThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); - err = TestThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); - err = TestWaitFor100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read ColorLoopTime attribute from DUT\n"); - err = TestReadColorLoopTimeAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStartEnhancedHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); - err = TestWaitFor5s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for 5S\n"); - err = TestWaitFor5s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for 5S\n"); - err = TestWaitFor5s_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Wait for 5S\n"); - err = TestWaitFor5s_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Wait 10ms\n"); - err = TestWait10ms_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Wait for 5S\n"); - err = TestWaitFor5s_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Wait for 5S\n"); - err = TestWaitFor5s_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Wait for 5S\n"); - err = TestWaitFor5s_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Wait for 5S\n"); - err = TestWaitFor5s_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Turn Off light for color control tests\n"); - err = TestTurnOffLightForColorControlTests_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 72; - - chip::Optional mNodeId; - chip::Optional mTimeout; - chip::Optional mCluster; - chip::Optional mEndpoint; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:4U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:5U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:8U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:160U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep5d; - - CHIP_ERROR TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep5d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep6c; - - CHIP_ERROR TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep6c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep6c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep8d; - - CHIP_ERROR TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep8d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_33() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep9c; - - CHIP_ERROR TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep9c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep9c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10ms_40() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:2U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_47() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep12d; - - CHIP_ERROR TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep12d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_50() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep13c; - - CHIP_ERROR TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep13c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep13c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:2U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_61() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep15d; - - CHIP_ERROR TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep15d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_64() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep16b; - - CHIP_ERROR TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep16b = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep16b)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightForColorControlTests_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light for color control tests: Error: %@", err); - } else { - NSLog(@"Turn Off light for color control tests: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestColorControl_9_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestColorControl_9_2() - : TestCommandBridge("TestColorControl_9_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestColorControl_9_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); - err = TestThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); - err = TestThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); - err = TestWaitFor100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read ColorLoopDirection attribute from DUT.\n"); - err = TestReadColorLoopDirectionAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopTime attribute from DUT.\n"); - err = TestReadColorLoopTimeAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestReadColorLoopStartEnhancedHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read ColorLoopActive attribute from DUT.\n"); - err = TestReadColorLoopActiveAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for 5S\n"); - err = TestWaitFor5s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); - err = TestWaitFor5s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read ColorLoopDirection attribute from DUT.\n"); - err = TestReadColorLoopDirectionAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait for 5S\n"); - err = TestWaitFor5s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait for 5S\n"); - err = TestWaitFor5s_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read EnhancedCurrentHue attribute from DUT.\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light for color control tests\n"); - err = TestTurnOffLightForColorControlTests_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:15U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:5U]; - params.startHue = - [NSNumber numberWithUnsignedShort:160U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopTime attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopTime attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueValue; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueValue2; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueValue2 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueValue3; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueValue3 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueValue3)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightForColorControlTests_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light for color control tests: Error: %@", err); - } else { - NSLog(@"Turn off light for color control tests: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CDOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CDOCONC_1_1() - : TestCommandBridge("Test_TC_CDOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CDOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F02 && CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F02 && !CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F03 && CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F03 && !CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F04 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F04 && !CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F05 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F05 && !CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.A0007 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !CDOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CDOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CDOCONC_2_1() - : TestCommandBridge("Test_TC_CDOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CDOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CMOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CMOCONC_1_1() - : TestCommandBridge("Test_TC_CMOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CMOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F02 && CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F02 && !CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F03 && CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F03 && !CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F04 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F04 && !CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F05 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F05 && !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.A0007 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !CMOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CMOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CMOCONC_2_1() - : TestCommandBridge("Test_TC_CMOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CMOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLDCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLDCONC_1_1() - : TestCommandBridge("Test_TC_FLDCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLDCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F02 && FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F02 && !FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F03 && FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F03 && !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F04 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F04 && !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F05 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F05 && !FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.A0007 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !FLDCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLDCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLDCONC_2_1() - : TestCommandBridge("Test_TC_FLDCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLDCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_NDOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_NDOCONC_1_1() - : TestCommandBridge("Test_TC_NDOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_NDOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F02 && NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F02 && !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F03 && NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F03 && !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F04 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F04 && NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F05 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F05 && !NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.A0007 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !NDOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_NDOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_NDOCONC_2_1() - : TestCommandBridge("Test_TC_NDOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_NDOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OZCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OZCONC_1_1() - : TestCommandBridge("Test_TC_OZCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OZCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F02 && OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F02 && !OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F03 && OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F03 && !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F04 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F04 && !OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F05 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F05 && !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("OZCONC.S.A0007 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !OZCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OZCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OZCONC_2_1() - : TestCommandBridge("Test_TC_OZCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OZCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("OZCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("OZCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("OZCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("OZCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("OZCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMHCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMHCONC_1_1() - : TestCommandBridge("Test_TC_PMHCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMHCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F02 && PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F02 && !PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F03 && PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F03 && !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F04 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F04 && PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F05 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F05 && !PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.A0007 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMHCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMHCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMHCONC_2_1() - : TestCommandBridge("Test_TC_PMHCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMHCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMICONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMICONC_1_1() - : TestCommandBridge("Test_TC_PMICONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMICONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F02 && PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F02 && !PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F03 && PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F03 && !PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F04 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F04 && !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F05 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F05 && !PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMICONC.S.A0007 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMICONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMICONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMICONC_2_1() - : TestCommandBridge("Test_TC_PMICONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMICONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMICONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMICONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMICONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMICONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMICONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMKCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMKCONC_1_1() - : TestCommandBridge("Test_TC_PMKCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMKCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F02 && PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F02 && !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F03 && PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F03 && !PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F04 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F04 && !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F05 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F05 && !PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.A0007 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMKCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMKCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMKCONC_2_1() - : TestCommandBridge("Test_TC_PMKCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMKCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RNCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RNCONC_1_1() - : TestCommandBridge("Test_TC_RNCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RNCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F02 && RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F02 && !RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F03 && RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F03 && !RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F04 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F04 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F05 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F05 && !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("RNCONC.S.A0007 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !RNCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RNCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RNCONC_2_1() - : TestCommandBridge("Test_TC_RNCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RNCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("RNCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: H reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("RNCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("RNCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("RNCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("RNCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TVOCCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TVOCCONC_1_1() - : TestCommandBridge("Test_TC_TVOCCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TVOCCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F02 && TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F02 && !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F03 && TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F03 && !TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F04 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F04 && !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F05 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F05 && !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.A0007 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TVOCCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TVOCCONC_2_1() - : TestCommandBridge("Test_TC_TVOCCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TVOCCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OPCREDS_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OPCREDS_1_2() - : TestCommandBridge("Test_TC_OPCREDS_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OPCREDS_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPCREDS_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPCREDS_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BINFO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BINFO_1_1() - : TestCommandBridge("Test_TC_BINFO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BINFO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BINFO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BINFO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PartNumber) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductURL) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000d")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(ProductLabel) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000e")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(SerialNumber) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000f")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0010")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(Reachable) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0011")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeReachableInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(UniqueID) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0012")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(ProductAppearance) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0014")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeProductAppearanceInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !BINFO.S.E00 && !BINFO.S.E01 && !BINFO.S.E02 && !BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH reads BINFO.S.E00(StartUp) event in EventList\n"); - if (ShouldSkip("BINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: TH reads BINFO.S.E01(ShutDown) event in EventList\n"); - if (ShouldSkip("BINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: TH reads BINFO.S.E02(Leave) event in EventList\n"); - if (ShouldSkip("BINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5e: TH reads (ReachableChanged) event in EventList\n"); - if (ShouldSkip("BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeReachableInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeProductAppearanceInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(ProductAppearance) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(ProductAppearance) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CNET_1_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CNET_1_3() - : TestCommandBridge("Test_TC_CNET_1_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CNET_1_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CNET_1_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CNET_1_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip(" !CNET.S.F00 && !CNET.S.F01 && !CNET.S.F02 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads the global attribute: FeatureMap when CNET.S.F00 is set\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads the global attribute: FeatureMap when CNET.S.F01 is set\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads the global attribute: FeatureMap when CNET.S.F02 is set\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true\n"); - if (ShouldSkip("CNET.S.F00 || CNET.S.F01 || CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads the feature dependent attribute(ScanMaxTimeSeconds): AttributeList\n"); - if (ShouldSkip("CNET.S.F00 || CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentAttributeScanMaxTimeSecondsAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads the feature dependent attribute(ConnectMaxTimeSeconds) in AttributeList\n"); - if (ShouldSkip("CNET.S.F00 || CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentAttributeConnectMaxTimeSecondsInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads WIFI related attribute (SupportedWiFiBands) in AttributeList\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep4fThReadsWifiRelatedAttributeSupportedWiFiBandsInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads Thread related attribute (SupportedWiFiBands and ThreadVersion) in AttributeList\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep4gThReadsThreadRelatedAttributeSupportedWiFiBandsAndThreadVersionInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH)\n"); - if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true)\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6c: TH reads AcceptedCommandList attribute from DUT. If DUT supports Thread related features(CNET.S.F01(TH) is true)\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep6cThReadsAcceptedCommandListAttributeFromDutIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6d: TH reads AcceptedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(TH) is true)\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep6dThReadsAcceptedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7a: TH reads the GeneratedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true)\n"); - if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { - NextTest(); - return; - } - err = TestStep7aThReadsTheGeneratedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7b: Read the GeneratedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(ET) must be true)\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep7bReadTheGeneratedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the global attribute: FeatureMap when CNET.S.F00 is set: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the global attribute: FeatureMap when CNET.S.F00 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the global attribute: FeatureMap when CNET.S.F01 is set: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the global attribute: FeatureMap when CNET.S.F01 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the global attribute: FeatureMap when CNET.S.F02 is set: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the global attribute: FeatureMap when CNET.S.F02 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 4UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentAttributeScanMaxTimeSecondsAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the feature dependent attribute(ScanMaxTimeSeconds): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the feature dependent attribute(ScanMaxTimeSeconds): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentAttributeConnectMaxTimeSecondsInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the feature dependent attribute(ConnectMaxTimeSeconds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the feature dependent attribute(ConnectMaxTimeSeconds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsWifiRelatedAttributeSupportedWiFiBandsInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads WIFI related attribute (SupportedWiFiBands) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads WIFI related attribute (SupportedWiFiBands) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsThreadRelatedAttributeSupportedWiFiBandsAndThreadVersionInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads Thread related attribute (SupportedWiFiBands and ThreadVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads Thread related attribute (SupportedWiFiBands and ThreadVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsAcceptedCommandListAttributeFromDutIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT. If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsAcceptedCommandListAttributeFromDutIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads AcceptedCommandList attribute from DUT. If DUT supports Thread related features(CNET.S.F01(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads AcceptedCommandList attribute from DUT. If DUT supports Thread related features(CNET.S.F01(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsAcceptedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads AcceptedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads AcceptedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsTheGeneratedCommandListAttributeFromDutIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads the GeneratedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads the GeneratedCommandList attribute from DUT. If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bReadTheGeneratedCommandListAttributeFromDutIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Read the GeneratedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Error: %@", err); - } else { - NSLog(@"Step 7b: Read the GeneratedCommandList attribute from DUT. If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DESC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DESC_1_1() - : TestCommandBridge("Test_TC_DESC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DESC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DESC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DESC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList)\n"); - if (ShouldSkip("DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00\n"); - if (ShouldSkip("DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DLOG_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DLOG_1_1() - : TestCommandBridge("Test_TC_DLOG_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DLOG_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DLOG_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DLOG_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_1_1() - : TestCommandBridge("Test_TC_DGETH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGETH.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGETH.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads optional attribute(PHYRate) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads optional attribute(FullDuplex) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0007")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0008")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("( DGETH.S.F00 || DGETH.S.F01 )")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_2_1() - : TestCommandBridge("Test_TC_DGETH_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads PHYRate attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsPHYRateAttributeConstraints_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FullDuplex attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFullDuplexAttributeConstraints_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads PacketRxCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4aThReadsPacketRxCountAttributeConstraints_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4bRebootTargetDevice_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4cRebootTargetDeviceDUT_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: Upon a node reboot, PacketRxCount attribute value will be reset to 0\n"); - if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5a: TH reads PacketTxCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep5aThReadsPacketTxCountAttributeConstraints_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5b: TH reads PacketTxCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 8: TH reads OverrunCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsOverrunCountAttributeConstraints_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads CarrierDetect attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsCarrierDetectAttributeConstraints_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads TimeSinceReset attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsTimeSinceResetAttributeConstraints_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsPHYRateAttributeConstraints_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads PHYRate attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads PHYRate attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFullDuplexAttributeConstraints_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFullDuplexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("fullDuplex", "boolean", "boolean")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsPacketRxCountAttributeConstraints_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("packetRxCount", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("packetRxCount", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("packetRxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bRebootTargetDevice_4() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep4cRebootTargetDeviceDUT_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5aThReadsPacketTxCountAttributeConstraints_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("packetTxCount", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("packetTxCount", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("packetTxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TxErrCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("txErrCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CollisionCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("collisionCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsOverrunCountAttributeConstraints_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OverrunCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsCarrierDetectAttributeConstraints_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCarrierDetectWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("carrierDetect", "boolean", "boolean")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTimeSinceResetAttributeConstraints_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeSinceResetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("timeSinceReset", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("timeSinceReset", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("timeSinceReset", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_2_2() - : TestCommandBridge("Test_TC_DGETH_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a.1: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a1ThReadsPHYRateAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a.2: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a2ThReadsPHYRateAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a.3: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a3ThReadsPHYRateAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a.4: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a4ThReadsPHYRateAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a.5: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a5ThReadsPHYRateAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a.6: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a6ThReadsPHYRateAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a.7: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a7ThReadsPHYRateAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a.8: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a8ThReadsPHYRateAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a.9: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a9ThReadsPHYRateAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2a.10: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a10ThReadsPHYRateAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH reads PacketRxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep2bThReadsPacketRxCountAttributeValueFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2c: TH reads PacketTxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep2cThReadsPacketTxCountAttributeValueFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads TxErrCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep2dThReadsTxErrCountAttributeValueFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads CollisionCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep2eThReadsCollisionCountAttributeValueFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2f: TH reads OverrunCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep2fThReadsOverrunCountAttributeValueFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2g: Sends ResetCounts command\n"); - if (ShouldSkip("DGETH.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2gSendsResetCountsCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 2h: TH reads PacketRxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0002 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2hThReadsPacketRxCountAttributeValueFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 2i: TH reads PacketTxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0003 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2iThReadsPacketTxCountAttributeValueFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 2j: TH reads TxErrCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep2jThReadsTxErrCountAttributeValueFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2k: TH reads CollisionCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep2kThReadsCollisionCountAttributeValueFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 2l: TH reads OverrunCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep2lThReadsOverrunCountAttributeValueFromDut_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2a1ThReadsPHYRateAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a2ThReadsPHYRateAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a3ThReadsPHYRateAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a4ThReadsPHYRateAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a5ThReadsPHYRateAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a6ThReadsPHYRateAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a7ThReadsPHYRateAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a8ThReadsPHYRateAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a9ThReadsPHYRateAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a10ThReadsPHYRateAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull PacketRxCountValue; - - CHIP_ERROR TestStep2bThReadsPacketRxCountAttributeValueFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - PacketRxCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull PacketTxCountValue; - - CHIP_ERROR TestStep2cThReadsPacketTxCountAttributeValueFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - PacketTxCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull TxErrCountValue; - - CHIP_ERROR TestStep2dThReadsTxErrCountAttributeValueFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - TxErrCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CollisionCountValue; - - CHIP_ERROR TestStep2eThReadsCollisionCountAttributeValueFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - CollisionCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull OverrunCountValue; - - CHIP_ERROR TestStep2fThReadsOverrunCountAttributeValueFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - OverrunCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2gSendsResetCountsCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resetCountsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: Sends ResetCounts command: Error: %@", err); - } else { - NSLog(@"Step 2g: Sends ResetCounts command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2hThReadsPacketRxCountAttributeValueFromDut_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2iThReadsPacketTxCountAttributeValueFromDut_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2jThReadsTxErrCountAttributeValueFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("txErrCount", [value unsignedLongLongValue], TxErrCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2kThReadsCollisionCountAttributeValueFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("collisionCount", [value unsignedLongLongValue], CollisionCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2lThReadsOverrunCountAttributeValueFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("overrunCount", [value unsignedLongLongValue], OverrunCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLW_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLW_1_1() - : TestCommandBridge("Test_TC_FLW_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLW_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLW_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLW_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("FLW.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLABEL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLABEL_1_1() - : TestCommandBridge("Test_TC_FLABEL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLABEL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLABEL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLABEL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_1_1() - : TestCommandBridge("Test_TC_FAN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !FAN.S.F00 && !FAN.S.F01 && !FAN.S.F02 && !FAN.S.F03 && !FAN.S.F04 && !FAN.S.F05 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F03")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F05")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6:TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip(" !FAN.S.C00.Rsp ")) { - NextTest(); - return; - } - err = TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH Reads the optional command (Step) in AcceptedCommandList\n"); - if (ShouldSkip("FAN.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_1() - : TestCommandBridge("Test_TC_FAN_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the FanMode attribute\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the FanModeSequence attribute\n"); - if (ShouldSkip("FAN.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the PercentSetting attribute\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the the PercentCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fanMode", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeSequenceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fanModeSequence", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("fanModeSequence", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("fanModeSequence", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("percentSetting", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("percentSetting", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("percentSetting", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("percentCurrent", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("percentCurrent", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("percentCurrent", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_2() - : TestCommandBridge("Test_TC_FAN_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpeedMax attribute\n"); - if (ShouldSkip("FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpeedSetting attribute\n"); - if (ShouldSkip("FAN.S.A0005 && FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the SpeedCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0006 && FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull SpeedMaxValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedMaxWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("speedMax", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedMax", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedMax", [value unsignedCharValue], 100U)); - { - SpeedMaxValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("speedSetting", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedSetting", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedSetting", [value unsignedCharValue], SpeedMaxValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("speedCurrent", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedCurrent", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedCurrent", [value unsignedCharValue], SpeedMaxValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_3() - : TestCommandBridge("Test_TC_FAN_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the RockSupport attribute\n"); - if (ShouldSkip("FAN.S.A0007")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the RockSetting attribute\n"); - if (ShouldSkip("FAN.S.A0008")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRockSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("rockSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRockSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("rockSetting", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_4() - : TestCommandBridge("Test_TC_FAN_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the WindSupport attribute\n"); - if (ShouldSkip("FAN.S.A0009")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the WindSetting attribute\n"); - if (ShouldSkip("FAN.S.A000A")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("windSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("windSetting", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_3_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_3_6() - : TestCommandBridge("Test_TC_FAN_3_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_3_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH writes a value of Forward to the DUT\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep2ThWritesAValueOfForwardToTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestWait1000ms_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a value of Reverse to the DUT\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep4ThWritesAValueOfReverseToTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestWait1000ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThWritesAValueOfForwardToTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id airflowDirectionArgument; - airflowDirectionArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes a value of Forward to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes a value of Forward to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesAValueOfReverseToTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id airflowDirectionArgument; - airflowDirectionArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CGEN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CGEN_1_1() - : TestCommandBridge("Test_TC_CGEN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CGEN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); - err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CGEN_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CGEN_2_1() - : TestCommandBridge("Test_TC_CGEN_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CGEN_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH1 reads the BreadCrumb Attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH1 reads the BreadCrumb attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH1 reads the RegulatoryConfig attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH1 reads the LocationCapability attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0003")) { - NextTest(); - return; - } - err = TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535\n"); - if (ShouldSkip("CGEN.S.A0001")) { - NextTest(); - return; - } - err = TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0004")) { - NextTest(); - return; - } - err = TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("breadcrumb", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("regulatoryConfig", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("regulatoryConfig", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationCapabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("locationCapability", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("locationCapability", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBasicCommissioningInfoWithCompletion:^(MTRGeneralCommissioningClusterBasicCommissioningInfo * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Error: %@", err); - } else { - NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGGEN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGGEN_1_1() - : TestCommandBridge("Test_TC_DGGEN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGGEN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGGEN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGGEN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(TotalOperationalHours) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeTotalOperationalHoursInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(BootReason) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeBootReasonInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(ActiveHardwareFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0005")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeActiveHardwareFaultsInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(ActiveRadioFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0006")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeActiveRadioFaultsInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(ActiveNetworkFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0007")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeActiveNetworkFaultsInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: TH reads optional event(HardwareFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: TH reads optional event(RadioFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: TH reads optional event(NetworkFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: TH reads from the DUT the AcceptedCommandList attribute\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeTotalOperationalHoursInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(TotalOperationalHours) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(TotalOperationalHours) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeBootReasonInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(BootReason) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(BootReason) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeActiveHardwareFaultsInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(ActiveHardwareFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(ActiveHardwareFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeActiveRadioFaultsInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(ActiveRadioFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(ActiveRadioFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeActiveNetworkFaultsInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(ActiveNetworkFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(ActiveNetworkFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 2UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_GRPKEY_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_GRPKEY_1_1() - : TestCommandBridge("Test_TC_GRPKEY_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_GRPKEY_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !GRPKEY.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("GRPKEY.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_GRPKEY_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_GRPKEY_2_2() - : TestCommandBridge("Test_TC_GRPKEY_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_GRPKEY_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.\n"); - if (ShouldSkip("GRPKEY.S.A0003")) { - NextTest(); - return; - } - err = TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { - NextTest(); - return; - } - err = TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { - NextTest(); - return; - } - err = TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 21: TH sends KeySetWrite command to DUT until size of list for TH’s fabric in GroupKeyMap attribute contains Max_GrpKey entries, starting with GroupKeySetID 1 and incrementing by 1 each time.\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 23: TH sends KeySetReadAllIndices command to DUT.\n"); - if (ShouldSkip("GRPKEY.S.C04.Rsp && GRPKEY.S.C05.Tx && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 34; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull Max_GrpKey; - - CHIP_ERROR TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxGroupKeysPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - Max_GrpKey = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.groupKeySet; - VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); - VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); - VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); - VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); - VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); - VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 18446744073709551613ULL)); - VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); - VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Error: %@", err); - } else { - NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Error: %@", err); - } else { - NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Error: %@", err); - } else { - NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd3\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd4\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:17446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd5\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:17446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Error: %@", err); - } else { - NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); - } else { - NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.groupKeySet; - VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); - VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); - VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); - VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); - VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); - VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 17446744073709551613ULL)); - VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); - VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 17446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:27U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); - } else { - NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Error: %@", err); - } else { - NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Error: %@", err); - } else { - NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Error: %@", err); - } else { - NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:27U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); - } else { - NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ICDM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ICDM_1_1() - : TestCommandBridge("Test_TC_ICDM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ICDM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ICDM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ICDM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 && !ICDM.S.F01 && !ICDM.S.F02 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads FeatureMap attribute from DUT, bit 0 is set to 1 if ICDM.S.F00(UAT) is true,\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDutBit0IsSetTo1IfIcdmsf00uatIsTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads FeatureMap attribute from DUT, bit 1 is set to 1 if ICDM.S.F01(CIP) is true\n"); - if (ShouldSkip("ICDM.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDutBit1IsSetTo1IfIcdmsf01cipIsTrue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads FeatureMap attribute from DUT, bit 2 is set to 1 if ICDM.S.F02(UAT) is true,\n"); - if (ShouldSkip("ICDM.S.F02")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDutBit2IsSetTo1IfIcdmsf02uatIsTrue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Read the optional attribute(RegisteredClients) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Read the optional attribute(IcdCounter) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0005")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: Read the optional attribute(UserActiveModeTriggerHint) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0006")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalAttributeUserActiveModeTriggerHintInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: Read the optional attribute(UserActiveModeTriggerInstruction) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0007")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalAttributeUserActiveModeTriggerInstructionInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 && !ICDM.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6c: Read the optional command (StayActiveRequest) in AttributeList\n"); - if (ShouldSkip("ICDM.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads GeneratedCommandList attribute from DUT. The list MAY include these optional entries: 0x04: SHALL be included if and only if ICDM.S.C04.Tx(StayActiveResponse) \n"); - if (ShouldSkip("ICDM.S.C04.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDutTheListMayIncludeTheseOptionalEntries0x04ShallBeIncludedIfAndOnlyIfICDMSC04TxStayActiveResponse_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDutBit0IsSetTo1IfIcdmsf00uatIsTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 0 is set to 1 if ICDM.S.F00(UAT) is true,: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 0 is set to 1 if ICDM.S.F00(UAT) is true,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDutBit1IsSetTo1IfIcdmsf01cipIsTrue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 1 is set to 1 if ICDM.S.F01(CIP) is true: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 1 is set to 1 if ICDM.S.F01(CIP) is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDutBit2IsSetTo1IfIcdmsf02uatIsTrue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 2 is set to 1 if ICDM.S.F02(UAT) is true,: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT, bit 2 is set to 1 if ICDM.S.F02(UAT) is true,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalAttributeUserActiveModeTriggerHintInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerHint) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerHint) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalAttributeUserActiveModeTriggerInstructionInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerInstruction) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional attribute(UserActiveModeTriggerInstruction) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDutTheListMayIncludeTheseOptionalEntries0x04ShallBeIncludedIfAndOnlyIfICDMSC04TxStayActiveResponse_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT. The list MAY include these optional entries: 0x04: SHALL be included if and only if ICDM.S.C04.Tx(StayActiveResponse) : Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT. The list MAY include these optional entries: 0x04: SHALL be included if and only if ICDM.S.C04.Tx(StayActiveResponse) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_1_1() - : TestCommandBridge("Test_TC_I_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_1() - : TestCommandBridge("Test_TC_I_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the IdentifyTime attribute from the DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the IdentifyType attribute from the DUT\n"); - if (ShouldSkip("I.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_2() - : TestCommandBridge("Test_TC_I_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1a: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1b: TH reads the IdentifyType attribute from the DUT.\n"); - if (ShouldSkip("I.S.A0001")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).\n"); - if (ShouldSkip("I.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads immediately IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 10000ms\n"); - err = TestWait10000ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).\n"); - if (ShouldSkip("I.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads immediately IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: Verify that the device enters its identification state using the IdentifyType from Step 1b, in order to indicate to an observer which of several nodes and/or endpoints it is.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { - NextTest(); - return; - } - err = TestStep6aVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 15000ms\n"); - err = TestWait15000ms_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6b: Verify that the device terminates its identification state\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { - NextTest(); - return; - } - err = TestStep6bVerifyThatTheDeviceTerminatesItsIdentificationState_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull IdentifyTypeValue; - - CHIP_ERROR TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); - { - IdentifyTypeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:60U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 51U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 69U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:0U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Error: %@", err); - } else { - NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("IdentifyTime", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id identifyTimeArgument; - identifyTimeArgument = - [NSNumber numberWithUnsignedShort:15U]; - [cluster writeAttributeIdentifyTimeWithValue:identifyTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait15000ms_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 15000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bVerifyThatTheDeviceTerminatesItsIdentificationState_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_I_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_3() - : TestCommandBridge("Test_TC_I_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x00 (default)\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : DUT executes a blink effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABlinkEffect_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x02 (okay) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : DUT executes an okay effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesAnOkayEffect_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d:TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x0b (channel change) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2dTHSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : DUT executes a channel change effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesAChannelChangeEffect_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2f: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xfe (finish effect) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : DUT stops the breathe effect after the current effect sequence\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2h: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : DUT stops the breathe effect as soon as possible.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsTheBreatheEffectAsSoonAsPossible_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x42 (unknown).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check DUT executes a blink effect.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestCheckDutExecutesABlinkEffect_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : DUT stops any effect that may be still running as soon as possible\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:0U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x00 (default): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x00 (default): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABlinkEffect_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:2U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x02 (okay) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x02 (okay) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesAnOkayEffect_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2dTHSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:11U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d:TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x0b (channel change) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2d:TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x0b (channel change) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesAChannelChangeEffect_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2e: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:254U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xfe (finish effect) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2f: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xfe (finish effect) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2g: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x01 (breathe) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:255U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2h: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 2h: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsTheBreatheEffectAsSoonAsPossible_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:0U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:66U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x42 (unknown).: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0x00 (blink) and the effect variant field set to 0x42 (unknown).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckDutExecutesABlinkEffect_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:255U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends TriggerEffect command to DUT, with the effect identifier field set to 0xff (stop effect) and the effect variant field set to 0x00 (default).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_ILL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_1_1() - : TestCommandBridge("Test_TC_ILL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); - err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("ILL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList\n"); - if (ShouldSkip("ILL.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the AcceptedCommandList attribute from the DUT.\n"); - err = TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads the GeneratedCommandList attribute from the DUT.\n"); - err = TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ILL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_2_1() - : TestCommandBridge("Test_TC_ILL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT.\n"); - if (ShouldSkip("ILL.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the LightSensorType attribute from the DUT\n"); - if (ShouldSkip("ILL.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value unsignedShortValue], 65533U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value unsignedShortValue], 2U)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLightSensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lightSensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("lightSensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("lightSensorType", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ILL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_2_2() - : TestCommandBridge("Test_TC_ILL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH reads MinMeasuredValue attribute from DUT\n"); - if (ShouldSkip("ILL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2aThReadsMinMeasuredValueAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads MaxMeasuredValue attribute from DUT\n"); - if (ShouldSkip("ILL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Cover the sensor or darken the room\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep3CoverTheSensorOrDarkenTheRoom_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 1s\n"); - err = TestWait1s_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: Expose the sensor again to light\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5ExposeTheSensorAgainToLight_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 1s\n"); - err = TestWait1s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2aThReadsMinMeasuredValueAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3CoverTheSensorOrDarkenTheRoom_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait1s_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ExposeTheSensorAgainToLight_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait1s_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_1_1() - : TestCommandBridge("Test_TC_LVL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LVL.S.F00 && !LVL.S.F01 && !LVL.S.F02 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4c: TH reads the optional attribute(MinLevel) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeMinLevelInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads the optional attribute(MaxLevel) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeMaxLevelInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4e: TH reads the optional attribute(OnOffTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeOnOffTransitionTimeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4f: TH reads the optional attribute(OnTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributeOnTransitionTimeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4g: TH reads the optional attribute(OffTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeOffTransitionTimeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4h: TH reads the optional attribute(DefaultMoveRate) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalAttributeDefaultMoveRateInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6a.1: TH reads the Feature-dependent(LVL.S.F02) command in AcceptedCommandList\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep6a1ThReadsTheFeatureDependentLVLSF02CommandInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeMinLevelInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(MinLevel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(MinLevel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeMaxLevelInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(MaxLevel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(MaxLevel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeOnOffTransitionTimeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute(OnOffTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute(OnOffTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributeOnTransitionTimeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute(OnTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute(OnTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeOffTransitionTimeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(OffTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(OffTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalAttributeDefaultMoveRateInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional attribute(DefaultMoveRate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional attribute(DefaultMoveRate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6a1ThReadsTheFeatureDependentLVLSF02CommandInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a.1: TH reads the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a.1: TH reads the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_2_1() - : TestCommandBridge("Test_TC_LVL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the CurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the RemainingTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002 && LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheMinLevelAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheMinLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003 && LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); - if (ShouldSkip("LVL.S.F01 && LVL.S.A0002 && LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4b4cThReadsTheCurrentLevelAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); - if (ShouldSkip("LVL.S.A0002 && LVL.S.A0003 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4b4cThReadsTheCurrentLevelAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the CurrentFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the MinFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0005")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the MaxFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b & 7C TH reads the CurrentFrequency attribute\n"); - if (ShouldSkip("LVL.S.A0004 && LVL.S.A0005 && LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep7b7cThReadsTheCurrentFrequencyAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8: TH reads the OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheOnOffTransitionTimeAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 9a: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.F01 && LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep9aThReadsTheOnLevelAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9b: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep9bThReadsTheOnLevelAttributeFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 10: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 11: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 12: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 13: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep13ThReadsTheOptionsAttributeFromTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable CurrentLevelValue; - - CHIP_ERROR TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); - } - { - CurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinLevelValue; - - CHIP_ERROR TestStep3aThReadsTheMinLevelAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - { - MinLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinLevelFeatureMapNotSupportedValue; - - CHIP_ERROR TestStep3bThReadsTheMinLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); - { - MinLevelFeatureMapNotSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxLevelValue; - - CHIP_ERROR TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MaxLevel", actualValue, 254U)); - } - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelValue)); - { - MaxLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxLevelFeatureMapNotSupportedValue; - - CHIP_ERROR TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - { - MaxLevelFeatureMapNotSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinFrequencyValue; - - CHIP_ERROR TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); - { - MinFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxFrequencyValue; - - CHIP_ERROR TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); - { - MaxFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7b7cThReadsTheCurrentFrequencyAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Error: %@", err); - } else { - NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheOnOffTransitionTimeAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9aThReadsTheOnLevelAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelValue)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9bThReadsTheOnLevelAttributeFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsTheOptionsAttributeFromTheDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_2_2() - : TestCommandBridge("Test_TC_LVL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("OnOffTransitionTimeConfigValue", 0, UINT16_MAX, &mOnOffTransitionTimeConfigValue); - AddArgument("OnLevelConfigValue", 0, UINT8_MAX, &mOnLevelConfigValue); - AddArgument("OnTransitionTimeConfigValue", 0, UINT16_MAX, &mOnTransitionTimeConfigValue); - AddArgument("OffTransitionTimeConfigValue", 0, UINT16_MAX, &mOffTransitionTimeConfigValue); - AddArgument("DefaultMoveRateConfigValue", 0, UINT8_MAX, &mDefaultMoveRateConfigValue); - AddArgument("StartUpCurrentLevelConfigValue", 0, UINT8_MAX, &mStartUpCurrentLevelConfigValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the OnOffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads the OnOffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheOnLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2cThReadsTheOnLevelAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : writes back default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mOnOffTransitionTimeConfigValue; - chip::Optional mOnLevelConfigValue; - chip::Optional mOnTransitionTimeConfigValue; - chip::Optional mOffTransitionTimeConfigValue; - chip::Optional mDefaultMoveRateConfigValue; - chip::Optional mStartUpCurrentLevelConfigValue; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull OnOffTransitionTimeValue; - - CHIP_ERROR TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); - { - OnOffTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = mOnOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Error: %@", err); - } else { - NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, mOnOffTransitionTimeConfigValue.HasValue() ? mOnOffTransitionTimeConfigValue.Value() : 10U)); - } - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintNotValue("onOffTransitionTime", value, OnOffTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnLevelValue; - - CHIP_ERROR TestStep2aThReadsTheOnLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], 254U)); - } - { - OnLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = mOnLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mOnLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Error: %@", err); - } else { - NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsTheOnLevelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); - VerifyOrReturn(CheckValue("OnLevel", actualValue, mOnLevelConfigValue.HasValue() ? mOnLevelConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("onLevel", value, OnLevelValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnTransitionTimeValue; - - CHIP_ERROR TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); - } - { - OnTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onTransitionTimeArgument; - onTransitionTimeArgument = mOnTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:5U]; - [cluster writeAttributeOnTransitionTimeWithValue:onTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Error: %@", err); - } else { - NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnTransitionTime", actualValue)); - VerifyOrReturn(CheckValue("OnTransitionTime", actualValue, mOnTransitionTimeConfigValue.HasValue() ? mOnTransitionTimeConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - } - VerifyOrReturn(CheckConstraintNotValue("onTransitionTime", value, OnTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OffTransitionTimeValue; - - CHIP_ERROR TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); - } - { - OffTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id offTransitionTimeArgument; - offTransitionTimeArgument = mOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; - [cluster writeAttributeOffTransitionTimeWithValue:offTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Error: %@", err); - } else { - NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OffTransitionTime", actualValue)); - VerifyOrReturn(CheckValue("OffTransitionTime", actualValue, mOffTransitionTimeConfigValue.HasValue() ? mOffTransitionTimeConfigValue.Value() : 10U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - } - VerifyOrReturn(CheckConstraintNotValue("offTransitionTime", value, OffTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable DefaultMoveRatevalue; - - CHIP_ERROR TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); - } - { - DefaultMoveRatevalue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id defaultMoveRateArgument; - defaultMoveRateArgument = mDefaultMoveRateConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mDefaultMoveRateConfigValue.Value()] : [NSNumber numberWithUnsignedChar:111U]; - [cluster writeAttributeDefaultMoveRateWithValue:defaultMoveRateArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Error: %@", err); - } else { - NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("DefaultMoveRate", actualValue)); - VerifyOrReturn(CheckValue("DefaultMoveRate", actualValue, mDefaultMoveRateConfigValue.HasValue() ? mDefaultMoveRateConfigValue.Value() : 111U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("defaultMoveRate", value, DefaultMoveRatevalue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable StartUpCurrentLevelValue; - - CHIP_ERROR TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); - } - { - StartUpCurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpCurrentLevelArgument; - startUpCurrentLevelArgument = mStartUpCurrentLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mStartUpCurrentLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeStartUpCurrentLevelWithValue:startUpCurrentLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Error: %@", err); - } else { - NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpCurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("StartUpCurrentLevel", actualValue, mStartUpCurrentLevelConfigValue.HasValue() ? mStartUpCurrentLevelConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("startUpCurrentLevel", value, StartUpCurrentLevelValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"writes back default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"writes back default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_3_1() - : TestCommandBridge("Test_TC_LVL_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1ThWrites0ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes NULL to the OnLevel attribute\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep1aThWritesNullToTheOnLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentLevelAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10000ms\n"); - err = TestWait10000ms_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10000ms\n"); - err = TestWait10000ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10000ms\n"); - err = TestWait10000ms_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 5000ms\n"); - err = TestWait5000ms_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep5aThWrites0x00ToTheOptionsAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5b: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep5bThReadsTheOptionsAttributeFromTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsOnCommandToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5e: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentLevelAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5fThSendsOffCommandToDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5h: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentLevelAttributeFromDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5j: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentLevelAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5l: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentLevelAttributeFromDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 6a: TH writes 0x01 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep6aThWrites0x01ToTheOptionsAttribute_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 6b: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionsAttributeFromTheDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 6c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThSendsOnCommandToDut_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6e: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6eThReadsCurrentLevelAttributeFromDut_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThSendsOffCommandToDut_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6h: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6hThReadsCurrentLevelAttributeFromDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6j: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6jThReadsCurrentLevelAttributeFromDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6l: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6lThReadsCurrentLevelAttributeFromDut_46(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 47; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThWrites0ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWritesNullToTheOnLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = nil; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrites0x00ToTheOptionsAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsTheOptionsAttributeFromTheDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsOnCommandToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eThReadsCurrentLevelAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5fThSendsOffCommandToDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5hThReadsCurrentLevelAttributeFromDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:140U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5jThReadsCurrentLevelAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:160U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); - } else { - NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5lThReadsCurrentLevelAttributeFromDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrites0x01ToTheOptionsAttribute_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionsAttributeFromTheDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThSendsOnCommandToDut_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsCurrentLevelAttributeFromDut_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThSendsOffCommandToDut_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadsCurrentLevelAttributeFromDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:140U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadsCurrentLevelAttributeFromDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:160U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); - } else { - NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadsCurrentLevelAttributeFromDut_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_4_1() - : TestCommandBridge("Test_TC_LVL_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s)\n"); - if (ShouldSkip("LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5000ms\n"); - err = TestWait5000ms_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentLevelAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); - err = TestWait10s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 19s\n"); - err = TestWait19s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveWithOnOffParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:10U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable CurrentLevelValue; - - CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - } - { - CurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 230U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait19s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 19000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_5_1() - : TestCommandBridge("Test_TC_LVL_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1ThWrites0x00ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: Reads current level attribute from DUT\n"); - if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3cReadsCurrentLevelAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.\n"); - if (ShouldSkip("LVL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); - err = TestWait10s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10s\n"); - err = TestWait10s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); - err = TestWait10s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 5000ms\n"); - err = TestWait5000ms_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThWrites0x00ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStepWithOnOffParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:0U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadsCurrentLevelAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Reads current level attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: Reads current level attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStepParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:0U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_6_1() - : TestCommandBridge("Test_TC_LVL_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0x00ToTheOptionsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentLevelAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d: Wait 5000ms\n"); - err = TestStep2dWait5000ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3: After 5 seconds, TH sends a Stop command to the DUT\n"); - if (ShouldSkip("LVL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3After5SecondsThSendsAStopCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Physically verify that the device has stopped transitioning\n"); - if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C03.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsCurrentLevelAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5000ms\n"); - err = TestWait5000ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT\n"); - if (ShouldSkip("LVL.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Physically verify that the device has stopped transitioning\n"); - if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C07.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep7ThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWrites0x00ToTheOptionsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsCurrentLevelAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dWait5000ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3After5SecondsThSendsAStopCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStopParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThReadsCurrentLevelAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 64U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 86U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStopWithOnOffParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_7_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_7_1() - : TestCommandBridge("Test_TC_LVL_7_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("RandomLevelValue", 0, UINT8_MAX, &mRandomLevelValue); - AddArgument("RandomFrequencyValue", 0, UINT16_MAX, &mRandomFrequencyValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_7_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_7_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_7_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0x00ToTheOptionsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheMinLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); - err = TestWait100ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1dThReadsCurrentLevelAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheCurrentFrequencyAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH reads the MinFrequency attribute.\n"); - if (ShouldSkip("LVL.S.A0005")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheMinFrequencyAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.\n"); - if (ShouldSkip("LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax\n"); - if (ShouldSkip("LVL.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 100ms\n"); - err = TestWait100ms_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheCurrentFrequencyAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmax + 1\n"); - if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheCurrentFrequencyAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmin - 1\n"); - if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5bThReadsTheCurrentFrequencyAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mRandomLevelValue; - chip::Optional mRandomFrequencyValue; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0aThWrites0x00ToTheOptionsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull minLevelValue; - - CHIP_ERROR TestStep1aThReadsTheMinLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); - { - minLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull maxLevelValue; - - CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - { - maxLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = mRandomLevelValue.HasValue() ? [NSNumber numberWithUnsignedChar:mRandomLevelValue.Value()] : [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1dThReadsCurrentLevelAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, mRandomLevelValue.HasValue() ? mRandomLevelValue.Value() : 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CurrentFrequencyValue; - - CHIP_ERROR TestStep2aThReadsTheCurrentFrequencyAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); - { - CurrentFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinFrequencyValue; - - CHIP_ERROR TestStep2bThReadsTheMinFrequencyAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); - { - MinFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxFrequencyValue; - - CHIP_ERROR TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); - { - MaxFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Error: %@", err); - } else { - NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToClosestFrequencyParams alloc] init]; - params.frequency = mRandomFrequencyValue.HasValue() ? [NSNumber numberWithUnsignedShort:mRandomFrequencyValue.Value()] : [NSNumber numberWithUnsignedShort:30000U]; - [cluster moveToClosestFrequencyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsTheCurrentFrequencyAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThReadsTheCurrentFrequencyAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5bThReadsTheCurrentFrequencyAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LCFG_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LCFG_1_1() - : TestCommandBridge("Test_TC_LCFG_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LCFG_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LCFG_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LCFG_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LUNIT_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LUNIT_1_2() - : TestCommandBridge("Test_TC_LUNIT_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LUNIT_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LUNIT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LUNIT.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("LUNIT.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LUNIT_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LUNIT_3_1() - : TestCommandBridge("Test_TC_LUNIT_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LUNIT_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsFromTheDutTheTemperatureUnit_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes 0 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { - NextTest(); - return; - } - err = TestStep2ThWrites0ToTemperatureUnit_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTemperatureUnit_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes 1 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { - NextTest(); - return; - } - err = TestStep4ThWrites1ToTemperatureUnit_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheTemperatureUnit_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes 2 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { - NextTest(); - return; - } - err = TestStep6ThWrites2ToTemperatureUnit_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheTemperatureUnit_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes 5 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000")) { - NextTest(); - return; - } - err = TestStep8ThWrites5ToTemperatureUnit_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsFromTheDutTheTemperatureUnit_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("temperatureUnit", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThWrites0ToTemperatureUnit_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTemperatureUnit_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWrites1ToTemperatureUnit_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheTemperatureUnit_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWrites2ToTemperatureUnit_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheTemperatureUnit_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThWrites5ToTemperatureUnit_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LTIME_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LTIME_1_2() - : TestCommandBridge("Test_TC_LTIME_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LTIME_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT\n"); - if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT\n"); - if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - VerifyOrReturn(CheckConstraintMinValue("featureMap", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("featureMap", [value unsignedIntValue], 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LTIME_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LTIME_3_1() - : TestCommandBridge("Test_TC_LTIME_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LTIME_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads HourFormat attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsHourFormatAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.M.12HR")) { - NextTest(); - return; - } - err = TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep3ThReadsHourFormatAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.M.24HR")) { - NextTest(); - return; - } - err = TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep5ThReadsHourFormatAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads ActiveCalendarType attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads SupportedCalendarTypes attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0002")) { - NextTest(); - return; - } - err = TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes value in PIXIT.LTIME.SCT to ActiveCalendarType attribute, followed by reading the ActiveCalendarType attribute value\n"); - if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: Repeat step 8 for all the values in PIXIT.LTIME.SCT\n"); - if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH writes 50 to ActiveCalendarType attribute\n"); - if (ShouldSkip("LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep10ThWrites50ToActiveCalendarTypeAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes 5 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep11ThWrites5ToHourFormatAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsHourFormatAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("hourFormat", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsHourFormatAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("HourFormat", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsHourFormatAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("HourFormat", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveCalendarTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("activeCalendarType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("activeCalendarType", [value unsignedCharValue], 11U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedCalendarTypesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxLength("supportedCalendarTypes", value, 12)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThWrites50ToActiveCalendarTypeAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id activeCalendarTypeArgument; - activeCalendarTypeArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeActiveCalendarTypeWithValue:activeCalendarTypeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThWrites5ToHourFormatAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LWM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LWM_1_1() - : TestCommandBridge("Test_TC_LWM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LWM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("LWM.S.F00")) { - NextTest(); - return; - } - err = TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LWM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList\n"); - if (ShouldSkip("LWM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList\n"); - if (ShouldSkip("LWM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LWM_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LWM_2_1() - : TestCommandBridge("Test_TC_LWM_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("NewMode_CHANGE_OK", 0, UINT8_MAX, &mNewModeChangeOk); - AddArgument("NewMode_CHANGE_FAIL", 0, UINT8_MAX, &mNewModeChangeFail); - AddArgument("invalid_mode_th", 0, UINT8_MAX, &mInvalidModeTh); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LWM_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SupportedModes attribute.\n"); - if (ShouldSkip("LWM.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Manually put the device in a state from which it will FAIL to transition to PIXIT.LWM.MODE_CHANGE_FAIL\n"); - if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && LWM.S.M.CAN_MANUALLY_CONTROLLED && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001 && LWM.S.M.CAN_MANUALLY_CONTROLLED")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_FAIL\n"); - if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && LWM.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Manually put the device in a state from which it will SUCCESSFULLY transition to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.M.CAN_MANUALLY_CONTROLLED && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.M.CAN_MANUALLY_CONTROLLED && LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mNewModeChangeOk; - chip::Optional mNewModeChangeFail; - chip::Optional mInvalidModeTh; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 2)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull old_current_mode_dut; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - old_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = - [old_current_mode_dut copy]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull Step6_current_mode_dut; - - CHIP_ERROR TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - Step6_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, Step6_current_mode_dut)); - } - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull Step10_current_mode_dut; - - CHIP_ERROR TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - Step10_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = mNewModeChangeOk.HasValue() ? [NSNumber numberWithUnsignedChar:mNewModeChangeOk.Value()] : [NSNumber numberWithUnsignedChar:2U]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = mInvalidModeTh.HasValue() ? [NSNumber numberWithUnsignedChar:mInvalidModeTh.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_1_1() - : TestCommandBridge("Test_TC_WASHERCTRL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH\n"); - err = TestCommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false\n"); - if (ShouldSkip("!WASHERCTRL.S.F00 && !WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true)\n"); - if (ShouldSkip("WASHERCTRL.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true)\n"); - if (ShouldSkip("WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.\n"); - if (ShouldSkip("WASHERCTRL.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.\n"); - if (ShouldSkip("WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_2_1() - : TestCommandBridge("Test_TC_WASHERCTRL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SpinSpeedCurrentValue", 0, UINT8_MAX, &mSpinSpeedCurrentValue); - AddArgument("unsupportedSpinSpeedCurrentValue", 0, UINT8_MAX, &mUnsupportedSpinSpeedCurrentValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpinSpeeds attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a uint8 with value between 0 and numSpinSpeeds-1 inclusive.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1)\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 2 seconds\n"); - err = TestWait2Seconds_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSpinSpeedCurrentValue; - chip::Optional mUnsupportedSpinSpeedCurrentValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("spinSpeeds", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("spinSpeeds", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("spinSpeedCurrent", [value unsignedCharValue], 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id spinSpeedCurrentArgument; - spinSpeedCurrentArgument = mSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpinSpeedCurrent", actualValue)); - VerifyOrReturn(CheckValue("SpinSpeedCurrent", actualValue, mSpinSpeedCurrentValue.HasValue() ? mSpinSpeedCurrentValue.Value() : 3U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id spinSpeedCurrentArgument; - spinSpeedCurrentArgument = mUnsupportedSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:17U]; - [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_2_2() - : TestCommandBridge("Test_TC_WASHERCTRL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("NumberOfRinsesValue", 0, UINT8_MAX, &mNumberOfRinsesValue); - AddArgument("unsupportedNumberOfRinsesValue", 0, UINT8_MAX, &mUnsupportedNumberOfRinsesValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the NumberOfRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SupportedRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0003")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); - err = TestWait2Seconds_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Operate device to set the condition to read only\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceToSetTheConditionToReadOnly_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.\n"); - if (ShouldSkip("WASHERCTRL.S.M.ManuallyControlled && WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mNumberOfRinsesValue; - chip::Optional mUnsupportedNumberOfRinsesValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfRinses", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("numberOfRinses", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfRinses", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedRinsesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedRinses", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedRinses", value, 4)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id numberOfRinsesArgument; - numberOfRinsesArgument = mNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfRinses", actualValue, mNumberOfRinsesValue.HasValue() ? mNumberOfRinsesValue.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id numberOfRinsesArgument; - numberOfRinsesArgument = mUnsupportedNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Error: %@", err); - } else { - NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OTCCM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OTCCM_1_1() - : TestCommandBridge("Test_TC_OTCCM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OTCCM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OTCCM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OTCCM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if OTCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("OTCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfOtccmsf00deponoff_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!OTCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: Read the optional attribute(StartUpMode) in AttributeList\n"); - if (ShouldSkip("OTCCM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeStartUpModeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: Read the Feature dependent attribute(DEPONOFF) in AttributeList\n"); - if (ShouldSkip("OTCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cReadTheFeatureDependentAttributeDEPONOFFInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfOtccmsf00deponoff_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if OTCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if OTCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeStartUpModeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(StartUpMode) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(StartUpMode) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheFeatureDependentAttributeDEPONOFFInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the Feature dependent attribute(DEPONOFF) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the Feature dependent attribute(DEPONOFF) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRYERCTRL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRYERCTRL_1_1() - : TestCommandBridge("Test_TC_DRYERCTRL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRYERCTRL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRYERCTRL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRYERCTRL_2_1() - : TestCommandBridge("Test_TC_DRYERCTRL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("unsupportedSelectedDrynessLevel", 0, UINT8_MAX, &mUnsupportedSelectedDrynessLevel); - AddArgument("SupportedDrynessLevel", 0, UINT8_MAX, &mSupportedDrynessLevel); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRYERCTRL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels\n"); - if (ShouldSkip("DRYERCTRL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); - err = TestWait2Seconds_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Operate device to set the condition to read only\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DRYERCTRL.S.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceToSetTheConditionToReadOnly_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.\n"); - if (ShouldSkip("DRYERCTRL.S.M.ManuallyControlled && DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mUnsupportedSelectedDrynessLevel; - chip::Optional mSupportedDrynessLevel; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedDrynessLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedDrynessLevels", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedDrynessLevels", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("selectedDrynessLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("selectedDrynessLevel", [value unsignedCharValue], 15U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Error: %@", err); - } else { - NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SelectedDrynessLevel", actualValue)); - VerifyOrReturn(CheckValue("SelectedDrynessLevel", actualValue, mSupportedDrynessLevel.HasValue() ? mSupportedDrynessLevel.Value() : 1U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mUnsupportedSelectedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSelectedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Error: %@", err); - } else { - NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LOWPOWER_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LOWPOWER_1_1() - : TestCommandBridge("Test_TC_LOWPOWER_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LOWPOWER_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(6))); - VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 65530UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 65533UL)); - } - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 65533UL)); - } - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_1_2() - : TestCommandBridge("Test_TC_KEYPADINPUT_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !KEYPADINPUT.S.F00 && KEYPADINPUT.S.F01 && !KEYPADINPUT.S.F02 ")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_1_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_1_3() - : TestCommandBridge("Test_TC_APPLAUNCHER_1_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_1_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_1_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_1_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("APPLAUNCHER.S.F00")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !APPLAUNCHER.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(CatalogList) in AttributeList\n"); - if (ShouldSkip("APPLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList\n"); - if (ShouldSkip("APPLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_1_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_1_4() - : TestCommandBridge("Test_TC_MEDIAINPUT_1_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_1_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_1_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_1_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !MEDIAINPUT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAINPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(InputList) in AttributeList\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList\n"); - if (ShouldSkip("MEDIAINPUT.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WAKEONLAN_1_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WAKEONLAN_1_5() - : TestCommandBridge("Test_TC_WAKEONLAN_1_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WAKEONLAN_1_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_1_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_1_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(MACAddress) in AttributeList\n"); - if (ShouldSkip("WAKEONLAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the global attribute: AcceptedCommandList\n"); - err = TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the global attribute: GeneratedCommandList\n"); - err = TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_1_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_1_6() - : TestCommandBridge("Test_TC_CHANNEL_1_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_1_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_1_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_1_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: read the global attribute: ClusterRevision\n"); - err = TestStep1ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read the global attribute: FeatureMap\n"); - if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { - NextTest(); - return; - } - err = TestStep2aReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CHANNEL.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CHANNEL.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: Read the optional attribute(ChannelList): AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bReadTheOptionalAttributeChannelListAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: Reading optional attribute(Lineup) in AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cReadingOptionalAttributeLineupInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: Read the optional attribute(CurrentChannel): AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { - NextTest(); - return; - } - err = TestStep5aReadTheGlobalAttributeGeneratedCommandList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("CHANNEL.S.F00 || CHANNEL.S.F01")) { - NextTest(); - return; - } - err = TestStep5bReadTheGlobalAttributeGeneratedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 1: read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bReadTheOptionalAttributeChannelListAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadingOptionalAttributeLineupInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aReadTheGlobalAttributeGeneratedCommandList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bReadTheGlobalAttributeGeneratedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_1_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_1_7() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_1_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_1_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_1_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_1_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !MEDIAPLAYBACK.S.F00 && !MEDIAPLAYBACK.S.F01 ")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(StartTime) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(Duration) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004")) { - NextTest(); - return; - } - err = TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { - NextTest(); - return; - } - err = TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { - NextTest(); - return; - } - err = TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: TH reads the optional command(Previous) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4d: TH reads the optional command(Next) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4i: TH reads the optional command(Seek) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AUDIOOUTPUT_1_8 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_1_8() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_1_8") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_1_8() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_1_8\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_1_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TTH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !AUDIOOUTPUT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TGTNAV_1_9 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TGTNAV_1_9() - : TestCommandBridge("Test_TC_TGTNAV_1_9") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TGTNAV_1_9() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_1_9\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_1_9\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList\n"); - if (ShouldSkip("TGTNAV.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APBSC_1_10 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APBSC_1_10() - : TestCommandBridge("Test_TC_APBSC_1_10") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APBSC_1_10() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_1_10\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_1_10\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(VendorName) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3c: TH reads the optional attribute(VendorID) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3d: TH reads the optional attribute(ProductID) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0003")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_1_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_1_11() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_1_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_1_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_1_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_1_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("( !CONTENTLAUNCHER.S.F00 && !CONTENTLAUNCHER.S.F01 )")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute\n"); - if (ShouldSkip("CONTENTLAUNCHER.C.C00.Tx")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute\n"); - if (ShouldSkip("CONTENTLAUNCHER.C.C01.Tx")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ALOGIN_1_12 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ALOGIN_1_12() - : TestCommandBridge("Test_TC_ALOGIN_1_12") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ALOGIN_1_12() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_1_12\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_1_12\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LOWPOWER_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LOWPOWER_2_1() - : TestCommandBridge("Test_TC_LOWPOWER_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LOWPOWER_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends Sleep command to DUT\n"); - if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsSleepCommandToDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsSleepCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends Sleep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends Sleep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_3_2() - : TestCommandBridge("Test_TC_KEYPADINPUT_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends CEC Settings Keys(0x0A) to DUT\n"); - if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsCecSettingsKeys0x0AToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends CEC Home Keys(0x09) to DUT\n"); - if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsCecHomeKeys0x09ToDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsCecSettingsKeys0x0AToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:10U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsCecHomeKeys0x09ToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:9U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_3_3() - : TestCommandBridge("Test_TC_KEYPADINPUT_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends Numbers1\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1aThSendsNumbers1_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends Numbers2\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1bThSendsNumbers2_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends Numbers3\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1cThSendsNumbers3_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH sends Numbers4\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1dThSendsNumbers4_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH sends Numbers5\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1eThSendsNumbers5_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH sends Numbers6\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1fThSendsNumbers6_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1g: TH sends Numbers7\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1gThSendsNumbers7_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1h: TH sends Numbers8\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1hThSendsNumbers8_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 1i: TH sends Numbers9\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1iThSendsNumbers9_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsNumbers1_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:33U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends Numbers1: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends Numbers1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsNumbers2_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:34U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends Numbers2: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends Numbers2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThSendsNumbers3_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:35U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends Numbers3: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends Numbers3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThSendsNumbers4_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:36U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH sends Numbers4: Error: %@", err); - } else { - NSLog(@"Step 1d: TH sends Numbers4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThSendsNumbers5_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:37U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH sends Numbers5: Error: %@", err); - } else { - NSLog(@"Step 1e: TH sends Numbers5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThSendsNumbers6_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:38U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: TH sends Numbers6: Error: %@", err); - } else { - NSLog(@"Step 1f: TH sends Numbers6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1gThSendsNumbers7_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:39U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1g: TH sends Numbers7: Error: %@", err); - } else { - NSLog(@"Step 1g: TH sends Numbers7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1hThSendsNumbers8_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:40U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1h: TH sends Numbers8: Error: %@", err); - } else { - NSLog(@"Step 1h: TH sends Numbers8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1iThSendsNumbers9_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:41U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1i: TH sends Numbers9: Error: %@", err); - } else { - NSLog(@"Step 1i: TH sends Numbers9: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_3_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_3_5() - : TestCommandBridge("Test_TC_APPLAUNCHER_3_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_3_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog\n"); - if (ShouldSkip("APPLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_3_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_3_6() - : TestCommandBridge("Test_TC_APPLAUNCHER_3_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_3_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application\n"); - if (ShouldSkip("APPLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_10 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_10() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_10") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_10() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_10\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_10\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_11() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.\n"); - if (ShouldSkip("MEDIAINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.\n"); - if (ShouldSkip("MEDIAINPUT.S.A0001 && MEDIAINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster selectInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentInput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_12 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_12() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_12") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_12() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_12\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_12\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list\n"); - if (ShouldSkip("MEDIAINPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list\n"); - if (ShouldSkip("MEDIAINPUT.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster showInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster hideInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_13 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_13() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_13") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_13() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_13\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_13\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1\n"); - if (ShouldSkip("MEDIAINPUT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAINPUT.S.A0000 && MEDIAINPUT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inputList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - params.name = @"A1"; - [cluster renameInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_CHANNEL_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_1() - : TestCommandBridge("Test_TC_CHANNEL_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional)\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_5_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_2() - : TestCommandBridge("Test_TC_CHANNEL_5_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); - AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheChannelListAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1\n"); - if (ShouldSkip("CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: Verify that the channel has changed on the device\n"); - if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mMajornumber; - chip::Optional mMinornumber; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = mMajornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMajornumber.Value()] : [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = mMinornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMinornumber.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_5_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_3() - : TestCommandBridge("Test_TC_CHANNEL_5_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); - AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); - AddArgument("majornumber2", 0, UINT16_MAX, &mMajornumber2); - AddArgument("minornumber2", 0, UINT16_MAX, &mMinornumber2); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object\n"); - if (ShouldSkip("CHANNEL.S.A0001")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the ChannelList attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheChannelListAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends a SkipChannel command to the DUT with a value of 1\n"); - if (ShouldSkip("CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: Verify that the channel has changed on the device\n"); - if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mMajornumber; - chip::Optional mMinornumber; - chip::Optional mMajornumber2; - chip::Optional mMinornumber2; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheChannelListAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber2.HasValue() ? mMajornumber2.Value() : 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber2.HasValue() ? mMinornumber2.Value() : 1U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentChannel", "ChannelInfoStruct", "ChannelInfoStruct")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_1() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAPlayCommandToTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a Pause command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAPauseCommandToTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is paused\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsPaused_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp && MEDIAPLAYBACK.S.A0000")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH sends a Stop command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAStopCommandToTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that the media is stoped\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsStoped_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAPauseCommandToTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a Pause command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a Pause command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsPaused_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is pausedgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsAStopCommandToTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a Stop command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a Stop command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsStoped_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is stopedgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_2() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAPlayCommandToTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a StartOver command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAStartOverCommandToTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is started over\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsStartedOver_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a Next command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsANextCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that the next media item in the queue has been loaded\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH sends a Previous command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAPreviousCommandToTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Verify that the previous media item in the queue has been loaded\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Verify that the media has skipped forward 10 seconds\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasSkippedForward10Seconds_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that the media has skipped backward 10 seconds\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasSkippedBackward10Seconds_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 10: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAStartOverCommandToTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startOverWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a StartOver command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a StartOver command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsStartedOver_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media is started overgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThSendsANextCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster nextWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a Next command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a Next command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media item in the queue has been loadedgarbage: not in length on purpose", 59); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThSendsAPreviousCommandToTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster previousWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a Previous command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a Previous command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if previous media item in the queue has been loadedgarbage: not in length on purpose", 68); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster skipForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasSkippedForward10Seconds_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has skipped forward 10 secondsgarbage: not in length on purpose", 56); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster skipBackwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasSkippedBackward10Seconds_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has skipped backward 10 secondsgarbage: not in length on purpose", 57); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_3() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SeekPosition", 0, UINT64_MAX, &mSeekPosition); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a Seek command to the DUT with a Position value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the media has moved to 10 seconds from the starting point\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the StartTime attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheStartTimeAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the SeekRangeEnd attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the SeekRangeStart attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the Duration attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheDurationAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media)\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : verify that the media has not moved.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasNotMoved_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSeekPosition; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has moved to 10 seconds from the starting pointgarbage: not in length on purpose", 73); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheStartTimeAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startTime", "epoch_us", "epoch_us")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("seekRangeEnd", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("seekRangeEnd", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("seekRangeEnd", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("seekRangeStart", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("seekRangeStart", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("seekRangeStart", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheDurationAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("duration", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("duration", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("duration", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - VerifyOrReturn(CheckConstraintNotValue("duration", value, 0ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = mSeekPosition.HasValue() ? [NSNumber numberWithUnsignedLongLong:mSeekPosition.Value()] : [NSNumber numberWithUnsignedLongLong:100000000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasNotMoved_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has not movedgarbage: not in length on purpose", 39); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_MEDIAPLAYBACK_6_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_4() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a FastForward command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsAFastForwardCommandToTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends a FastForward command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAFastForwardCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : verify that the media play speed has increased.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlaySpeedHasIncreased_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends a Rewind command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsARewindCommandToTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : verify that the media play has reversed direction.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlayHasReversedDirection_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 11: TH sends a Rewind command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsARewindCommandToTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : verify that the media play speed has increased in the reverse direction.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 12: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 13: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsAPlayCommandToTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : verify that the media is has resumed playing forward at the default speed.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 15: STH sends consecutive FastForward commands up to the manufacturer defined max speed\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16: TH sends consecutive Rewind commands up to the manufacturer defined max speed\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAFastForwardCommandToTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a FastForward command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a FastForward command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsAFastForwardCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a FastForward command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a FastForward command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreased_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play speed has increased.garbage: not in length on purpose", 51); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 2.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsARewindCommandToTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends a Rewind command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends a Rewind command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlayHasReversedDirection_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play has reversed directiongarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsARewindCommandToTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a Rewind command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a Rewind command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play speed has increased in the reverse directiongarbage: not in length on purpose", 75); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -2.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsAPlayCommandToTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media is has resumed playing forward at the default speedgarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_AUDIOOUTPUT_7_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_7_1() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_7_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheOutputListAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1\n"); - if (ShouldSkip("AUDIOOUTPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentOutput attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheOutputListAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the OutputList attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the OutputList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster selectOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentOutput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AUDIOOUTPUT_7_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_7_2() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_7_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheOutputListAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest'\n"); - if (ShouldSkip("AUDIOOUTPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the OutputList attribute from the DUT. Verify that the output at the index provided in step 2 has the name CertTest\n"); - if (ShouldSkip("PICS_USER_PROMPT && AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSArray * _Nonnull audioOutputListValues; - - CHIP_ERROR TestStep1ThReadsTheOutputListAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); - { - audioOutputListValues = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - params.name = @"CertTest"; - [cluster renameOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_TGTNAV_8_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TGTNAV_8_1() - : TestCommandBridge("Test_TC_TGTNAV_8_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("targetvalue", 0, UINT8_MAX, &mTargetvalue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TGTNAV_8_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_8_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_8_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the CurrentTarget attribute\n"); - if (ShouldSkip("TGTNAV.S.A0001")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheCurrentTargetAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads the TargetList attribute\n"); - if (ShouldSkip("TGTNAV.S.A0000")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheTargetListAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH Sends a NavigateTarget command\n"); - if (ShouldSkip("TGTNAV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsANavigateTargetCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH reads the CurrentTarget attribute\n"); - if (ShouldSkip("TGTNAV.S.A0001 && TGTNAV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheCurrentTargetAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTargetvalue; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsTheCurrentTargetAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentTarget", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentTarget", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentTarget", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSArray * _Nonnull TargetListValues; - - CHIP_ERROR TestStep1bThReadsTheTargetListAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the TargetList attribute: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the TargetList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("targetList", "list", "list")); - { - TargetListValues = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsANavigateTargetCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; - params.target = mTargetvalue.HasValue() ? [NSNumber numberWithUnsignedChar:mTargetvalue.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster navigateTargetWithParams:params completion: - ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH Sends a NavigateTarget command: Error: %@", err); - } else { - NSLog(@"Step 2a: TH Sends a NavigateTarget command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsTheCurrentTargetAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentTarget", actualValue, mTargetvalue.HasValue() ? mTargetvalue.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APBSC_9_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APBSC_9_1() - : TestCommandBridge("Test_TC_APBSC_9_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APBSC_9_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_9_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_9_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the VendorName attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheVendorNameAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the VendorID attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheVendorIDAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the ApplicationName attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads the ProductID attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheProductIDAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads the Application attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0004")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheApplicationAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads the Status attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0005")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheStatusAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads the ApplicationVersion attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0006")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the AllowedVendorList attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0007")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheVendorNameAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("vendorName", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("vendorName", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheVendorIDAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("vendorID", "vendor_id", "vendor_id")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("applicationName", "long_char_string", "long_char_string")); - VerifyOrReturn(CheckConstraintMaxLength("applicationName", value, 256)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheProductIDAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("productID", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("productID", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("productID", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheApplicationAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Application attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Application attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("application", "ApplicationStruct", "ApplicationStruct")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheStatusAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the Status attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the Status attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("applicationVersion", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("applicationVersion", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("allowedVendorList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_1() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the AcceptHeader attribute from the DUT\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptHeader", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedStreamingProtocols", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WAKEONLAN_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WAKEONLAN_4_1() - : TestCommandBridge("Test_TC_WAKEONLAN_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WAKEONLAN_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the MACAddress attribute from the DUT\n"); - if (ShouldSkip("WAKEONLAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheMACAddressAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a Sleep command to DUT\n"); - if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsASleepCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends a Wake-On LAN magic packet containing the MAC address from step 1\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheMACAddressAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 12)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsASleepCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Sleep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Sleep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_ALOGIN_12_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ALOGIN_12_1() - : TestCommandBridge("Test_TC_ALOGIN_12_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("TempAccountIdentifier", &mTempAccountIdentifier); - AddArgument("catalogVendorId", 0, UINT16_MAX, &mCatalogVendorId); - AddArgument("applicationId", &mApplicationId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ALOGIN_12_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_12_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_12_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Launch an app with the provided a application ID\n"); - if (ShouldSkip("APPLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestLaunchAnAppWithTheProvidedAApplicationId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Login command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C02.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTempAccountIdentifier; - chip::Optional mCatalogVendorId; - chip::Optional mApplicationId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestLaunchAnAppWithTheProvidedAApplicationId_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = mCatalogVendorId.HasValue() ? [NSNumber numberWithUnsignedShort:mCatalogVendorId.Value()] : [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = mApplicationId.HasValue() ? [[NSString alloc] initWithBytes:mApplicationId.Value().data() length:mApplicationId.Value().size() encoding:NSUTF8StringEncoding] : @"exampleid"; - - params.data = - [[NSData alloc] initWithBytes:"Hello World" length:11]; - [cluster launchAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch an app with the provided a application ID: Error: %@", err); - } else { - NSLog(@"Launch an app with the provided a application ID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull setupPIN; - - CHIP_ERROR TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; - params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; - [cluster getSetupPINWithParams:params completion: - ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("setupPIN", values.setupPIN, 8)); - { - setupPIN = values.setupPIN; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; - params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; - params.setupPIN = - [setupPIN copy]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster loginWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster logoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_3() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("data", &mData); - AddArgument("SearchValue", &mSearchValue); - AddArgument("ExternalIdName", &mExternalIdName); - AddArgument("ExternalIdValue", &mExternalIdValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT present via its user interface a list of matches based on the provided search criteria.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should also begin playing content that best matched the given search criteria\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mData; - chip::Optional mSearchValue; - chip::Optional mExternalIdName; - chip::Optional mExternalIdValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:false]; - params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:false]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT present via its user interface a list of matches based on the provided search criteria.garbage: not in length on purpose", 111); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:false]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT begin playing content that best matched the given search criteriagarbage: not in length on purpose", 89); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_CONTENTLAUNCHER_10_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_5() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("GoodURL", &mGoodURL); - AddArgument("BadURL", &mBadURL); - AddArgument("UnauthorizedURL", &mUnauthorizedURL); - AddArgument("DisplayContent", &mDisplayContent); - AddArgument("providerNameString", &mProviderNameString); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT launched the content at the given URL\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT launched the content at the given URL with the given display string in the application-specific description area\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT launched the content at the given URL with the player interface updated as per the provided branding information\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mGoodURL; - chip::Optional mBadURL; - chip::Optional mUnauthorizedURL; - chip::Optional mDisplayContent; - chip::Optional mProviderNameString; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URLgarbage: not in length on purpose", 61); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.displayString = mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the given display string in the application-specific description areagarbage: not in length on purpose", 136); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the player interface updated as per the provided branding informationgarbage: not in length on purpose", 136); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mBadURL.HasValue() ? [[NSString alloc] initWithBytes:mBadURL.Value().data() length:mBadURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://badurl"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mUnauthorizedURL.HasValue() ? [[NSString alloc] initWithBytes:mUnauthorizedURL.Value().data() length:mUnauthorizedURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/badauth"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_7() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("PopularityName", &mPopularityName); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 27; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPopularityName; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Gaby sHoffman"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"PBS"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Snow White"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:false]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Spike Lee"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Football games"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Star Wars"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:6U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Horror"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:7U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"NCAA"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:8U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mPopularityName.HasValue() ? [[NSString alloc] initWithBytes:mPopularityName.Value().data() length:mPopularityName.Value().size() encoding:NSUTF8StringEncoding] : @"popular content"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:9U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Netflix"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:10U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"football"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:11U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Arsenel"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Error: %@", err); - } else { - NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:12U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"TVSeries"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_MOD_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MOD_1_1() - : TestCommandBridge("Test_TC_MOD_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MOD_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MOD_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MOD_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("MOD.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !MOD.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); - if (ShouldSkip("MOD.S.A0004")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT\n"); - if (ShouldSkip("MOD.S.F00 && MOD.S.A0005")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class OTA_SuccessfulTransfer : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - OTA_SuccessfulTransfer() - : TestCommandBridge("OTA_SuccessfulTransfer") - , mTestIndex(0) - { - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("requestorNodeId", 0, UINT64_MAX, &mRequestorNodeId); - AddArgument("providerNodeId", 0, UINT64_MAX, &mProviderNodeId); - AddArgument("providerPayload", &mProviderPayload); - AddArgument("providerDiscriminator", 0, UINT16_MAX, &mProviderDiscriminator); - AddArgument("providerPort", 0, UINT16_MAX, &mProviderPort); - AddArgument("providerKvs", &mProviderKvs); - AddArgument("otaImageFilePath", &mOtaImageFilePath); - AddArgument("rawImageFilePath", &mRawImageFilePath); - AddArgument("rawImageContent", &mRawImageContent); - AddArgument("downloadImageFilePath", &mDownloadImageFilePath); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~OTA_SuccessfulTransfer() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: OTA_SuccessfulTransfer\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: OTA_SuccessfulTransfer\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Create OTA image\n"); - err = TestCreateOtaImage_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Start the provider with an image\n"); - err = TestStartTheProviderWithAnImage_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Commission the provider from alpha\n"); - err = TestCommissionTheProviderFromAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned provider to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Install ACL for QueryImage\n"); - err = TestInstallAclForQueryImage_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the requestor\n"); - err = TestStopTheRequestor_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Start the requestor with an OTA download path\n"); - err = TestStartTheRequestorWithAnOtaDownloadPath_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned requestor to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Send an announce OTA provider command to the requestor\n"); - err = TestSendAnAnnounceOtaProviderCommandToTheRequestor_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait for transfer complete message\n"); - err = TestWaitForTransferCompleteMessage_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Compare original file to downloaded file\n"); - err = TestCompareOriginalFileToDownloadedFile_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mEndpoint; - chip::Optional mRequestorNodeId; - chip::Optional mProviderNodeId; - chip::Optional mProviderPayload; - chip::Optional mProviderDiscriminator; - chip::Optional mProviderPort; - chip::Optional mProviderKvs; - chip::Optional mOtaImageFilePath; - chip::Optional mRawImageFilePath; - chip::Optional mRawImageContent; - chip::Optional mDownloadImageFilePath; - chip::Optional mTimeout; - - CHIP_ERROR TestCreateOtaImage_0() - { - - chip::app::Clusters::SystemCommands::Commands::CreateOtaImage::Type value; - value.otaImageFilePath = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); - value.rawImageFilePath = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); - value.rawImageContent = mRawImageContent.HasValue() ? mRawImageContent.Value() : chip::Span("Have a hootenanny!", 18); - return CreateOtaImage("alpha", value); - } - - CHIP_ERROR TestStartTheProviderWithAnImage_1() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-ota-provider-appgarbage: not in length on purpose", 21); - value.discriminator.Emplace(); - value.discriminator.Value() = mProviderDiscriminator.HasValue() ? mProviderDiscriminator.Value() : 50U; - value.port.Emplace(); - value.port.Value() = mProviderPort.HasValue() ? mProviderPort.Value() : 5560U; - value.kvs.Emplace(); - value.kvs.Value() = mProviderKvs.HasValue() ? mProviderKvs.Value() : chip::Span("/tmp/chip_kvs_provider", 22); - value.filepath.Emplace(); - value.filepath.Value() = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionTheProviderFromAlpha_2() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; - value.payload = mProviderPayload.HasValue() ? mProviderPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestInstallAclForQueryImage_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:41UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Install ACL for QueryImage: Error: %@", err); - } else { - NSLog(@"Install ACL for QueryImage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopTheRequestor_5() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheRequestorWithAnOtaDownloadPath_6() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.otaDownloadPath.Emplace(); - value.otaDownloadPath.Value() = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); - return Start("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mRequestorNodeId.HasValue() ? mRequestorNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendAnAnnounceOtaProviderCommandToTheRequestor_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOTASoftwareUpdateRequestor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROTASoftwareUpdateRequestorClusterAnnounceOTAProviderParams alloc] init]; - params.providerNodeID = mProviderNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mProviderNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:12648430ULL]; - params.vendorID = - [NSNumber numberWithUnsignedShort:0U]; - params.announcementReason = - [NSNumber numberWithUnsignedChar:0U]; - params.endpoint = mEndpoint.HasValue() ? [NSNumber numberWithUnsignedShort:mEndpoint.Value()] : [NSNumber numberWithUnsignedShort:0U]; - [cluster announceOTAProviderWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send an announce OTA provider command to the requestor: Error: %@", err); - } else { - NSLog(@"Send an announce OTA provider command to the requestor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitForTransferCompleteMessage_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMessage::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - value.message = chip::Span("OTA image downloadedgarbage: not in length on purpose", 20); - return WaitForMessage("alpha", value); - } - - CHIP_ERROR TestCompareOriginalFileToDownloadedFile_10() - { - - chip::app::Clusters::SystemCommands::Commands::CompareFiles::Type value; - value.file1 = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); - value.file2 = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); - return CompareFiles("alpha", value); - } -}; - -class Test_TC_OCC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_1_1() - : TestCommandBridge("Test_TC_OCC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0022")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0030")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0031")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0032")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); - err = TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_2_1() - : TestCommandBridge("Test_TC_OCC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) Occupancy attribute\n"); - if (ShouldSkip("OCC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute\n"); - if (ShouldSkip("OCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute\n"); - if (ShouldSkip("OCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0022")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0030")) { - NextTest(); - return; - } - err = TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0031")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0032")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancy", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancy", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancy", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Error: %@", err); - } else { - NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIROccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIROccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIRUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIRUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicOccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactOccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_2_3() - : TestCommandBridge("Test_TC_OCC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads OccupancySensorType attribute from DUT\n"); - if (ShouldSkip("OCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT\n"); - if (ShouldSkip("OCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_1_1() - : TestCommandBridge("Test_TC_OO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("( !OO.S.F00 && !OO.S.F01 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OO.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_1() - : TestCommandBridge("Test_TC_OO_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheOnOffAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the GlobalSceneControl attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4000")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the OnTime attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4001")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheOnTimeAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the OffWaitTime attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4002")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the StartUpOnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheOnOffAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOff", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGlobalSceneControlWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("globalSceneControl", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheOnTimeAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffWaitTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("offWaitTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offWaitTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offWaitTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpOnOff", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_2() - : TestCommandBridge("Test_TC_OO_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThSendsOnCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsOffCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThSendsOffCommandToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5c: TH sends Toggle command to DUT\n"); - if (ShouldSkip("OO.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsToggleCommandToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 1000ms\n"); - err = TestWait1000ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH sends Toggle command to DUT\n"); - if (ShouldSkip("OO.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestThSendsToggleCommandToDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 1000ms\n"); - err = TestWait1000ms_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after toggle command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6a: Operate on device to set OnOff attribute manually to on\n"); - if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6c: Operate on device to set OnOff attribute manually to off\n"); - if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Reset Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestResetOffCommand_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThSendsOnCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsOffCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsOffCommandToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsToggleCommandToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster toggleWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends Toggle command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends Toggle command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsToggleCommandToDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster toggleWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends Toggle command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends Toggle command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after toggle command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after toggle command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Off Command: Error: %@", err); - } else { - NSLog(@"Reset Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_4() - : TestCommandBridge("Test_TC_OO_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsOnCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3bRebootTargetDevice_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3cRebootTargetDeviceDUT_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOnOffAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4bRebootTargetDevice_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4cRebootTargetDeviceDUT_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOnOffAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5bRebootTargetDevice_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5cRebootTargetDeviceDUT_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5dThReadsTheOnOffAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5e: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5eRebootTargetDevice_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5f: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5fRebootTargetDeviceDUT_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5g: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5gThReadsTheOnOffAttributeFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 6a: TH writes NULL to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6bRebootTargetDevice_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6cRebootTargetDeviceDUT_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOnOffAttributeFromTheDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6e: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThSendsOffCommandToDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6f: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6fThReadsTheOnOffAttributeFromTheDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6g: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6gRebootTargetDevice_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6h: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6hRebootTargetDeviceDUT_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6i: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6iThReadsTheOnOffAttributeFromTheDut_31(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 32; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsOnCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bRebootTargetDevice_3() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep3cRebootTargetDeviceDUT_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsTheOnOffAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bRebootTargetDevice_8() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep4cRebootTargetDeviceDUT_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4dThReadsTheOnOffAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bRebootTargetDevice_13() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep5cRebootTargetDeviceDUT_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep5dThReadsTheOnOffAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eRebootTargetDevice_17() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep5fRebootTargetDeviceDUT_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep5gThReadsTheOnOffAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = nil; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bRebootTargetDevice_22() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep6cRebootTargetDeviceDUT_23() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep6dThReadsTheOnOffAttributeFromTheDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThSendsOffCommandToDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6e: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsTheOnOffAttributeFromTheDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gRebootTargetDevice_28() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep6hRebootTargetDeviceDUT_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep6iThReadsTheOnOffAttributeFromTheDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OPSTATE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OPSTATE_1_1() - : TestCommandBridge("Test_TC_OPSTATE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OPSTATE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPSTATE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPSTATE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); - if (ShouldSkip("OPSTATE.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && OPSTATE.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Start) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Pause) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && !OPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip("(OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || OPSTATE.S.C03.Rsp)")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PS_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PS_1_1() - : TestCommandBridge("Test_TC_PS_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PS_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads ClusterRevision attribute.\n"); - err = TestStep2TestHarnessClientReadsClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !PS.S.F00 && !PS.S.F01 && !PS.S.F02 && !PS.S.F03 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F02")) { - NextTest(); - return; - } - err = TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F03")) { - NextTest(); - return; - } - err = TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: Test Harness Client reads AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: Test Harness Client reads AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F00")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheFeatureDependentPSSF00WiredAttributeInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads the Feature dependent(PS.S.F01-BAT) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F01")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentPSSF01BatAttributeInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentPSSF02RechgAttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F03")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: Test Harness Client reads EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PS.S.E00 && !PS.S.E01 && !PS.S.E02 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH reads PS.S.E00(WiredFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: TH reads PS.S.E01(BatFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: TH reads PS.S.E02(BatChargeFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E02")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: Test Harness Client reads AcceptedCommandList attribute.\n"); - err = TestStep6TestHarnessClientReadsAcceptedCommandListAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: Test Harness Client reads GeneratedCommandList attribute.\n"); - err = TestStep7TestHarnessClientReadsGeneratedCommandListAttribute_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheFeatureDependentPSSF00WiredAttributeInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentPSSF01BatAttributeInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentPSSF02RechgAttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6TestHarnessClientReadsAcceptedCommandListAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Test Harness Client reads AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: Test Harness Client reads AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7TestHarnessClientReadsGeneratedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Test Harness Client reads GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: Test Harness Client reads GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PS_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PS_2_1() - : TestCommandBridge("Test_TC_PS_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PS_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads Status from server DUT\n"); - if (ShouldSkip("PS.S.A0000")) { - NextTest(); - return; - } - err = TestStep2TestHarnessClientReadsStatusFromServerDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads Order from server DUT\n"); - if (ShouldSkip("PS.S.A0001")) { - NextTest(); - return; - } - err = TestStep3TestHarnessClientReadsOrderFromServerDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads Order from server DUT\n"); - if (ShouldSkip("PS.S.A0002")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsOrderFromServerDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT\n"); - if (ShouldSkip("PS.S.A0003")) { - NextTest(); - return; - } - err = TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT\n"); - if (ShouldSkip("PS.S.A0004")) { - NextTest(); - return; - } - err = TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: Test Harness Client reads WiredCurrentType from server DUT\n"); - if (ShouldSkip("PS.S.A0005")) { - NextTest(); - return; - } - err = TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT\n"); - if (ShouldSkip("PS.S.A0006")) { - NextTest(); - return; - } - err = TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Test Harness Client reads WiredNominalVoltage from server DUT\n"); - if (ShouldSkip("PS.S.A0007")) { - NextTest(); - return; - } - err = TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT\n"); - if (ShouldSkip("PS.S.A0008")) { - NextTest(); - return; - } - err = TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: Test Harness Client reads WiredPresent from Server DUT\n"); - if (ShouldSkip("PS.S.A0009")) { - NextTest(); - return; - } - err = TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A000a")) { - NextTest(); - return; - } - err = TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: Test Harness Client reads BatVoltage from Server DUT\n"); - if (ShouldSkip("PS.S.A000b")) { - NextTest(); - return; - } - err = TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: Test Harness Client reads BatPercentRemaining from Server DUT\n"); - if (ShouldSkip("PS.S.A000c")) { - NextTest(); - return; - } - err = TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: Test Harness Client reads BatTimeRemaining from Server DUT\n"); - if (ShouldSkip("PS.S.A000d")) { - NextTest(); - return; - } - err = TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: Test Harness Client reads BatChargeLevel from Server DUT\n"); - if (ShouldSkip("PS.S.A000e")) { - NextTest(); - return; - } - err = TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT\n"); - if (ShouldSkip("PS.S.A000f")) { - NextTest(); - return; - } - err = TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: Test Harness Client reads BatReplaceability from Server DUT\n"); - if (ShouldSkip("PS.S.A0010")) { - NextTest(); - return; - } - err = TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: Test Harness Client reads BatPresent from Server DUT\n"); - if (ShouldSkip("PS.S.A0011")) { - NextTest(); - return; - } - err = TestStep19TestHarnessClientReadsBatPresentFromServerDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: Test Harness Client readsActiveBatFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A0012")) { - NextTest(); - return; - } - err = TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: Test Harness Client reads BatReplacementDescription from Server DUT\n"); - if (ShouldSkip("PS.S.A0013")) { - NextTest(); - return; - } - err = TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: Test Harness Client reads BatCommonDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0014")) { - NextTest(); - return; - } - err = TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: Test Harness Client reads BatANSIDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0015")) { - NextTest(); - return; - } - err = TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: Test Harness Client reads BatIECDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0016")) { - NextTest(); - return; - } - err = TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT\n"); - if (ShouldSkip("PS.S.A0017")) { - NextTest(); - return; - } - err = TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 26: Test Harness Client reads BatCapacity from Server DUT\n"); - if (ShouldSkip("PS.S.A0018")) { - NextTest(); - return; - } - err = TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 27: Test Harness Client reads BatQuantity from Server DUT\n"); - if (ShouldSkip("PS.S.A0019")) { - NextTest(); - return; - } - err = TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 28: Test Harness Client reads BatChargeState from Server DUT\n"); - if (ShouldSkip("PS.S.A001a")) { - NextTest(); - return; - } - err = TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT\n"); - if (ShouldSkip("PS.S.A001b")) { - NextTest(); - return; - } - err = TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT\n"); - if (ShouldSkip("PS.S.A001c")) { - NextTest(); - return; - } - err = TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 31: Test Harness Client reads BatChargingCurrent from Server DUT\n"); - if (ShouldSkip("PS.S.A001d")) { - NextTest(); - return; - } - err = TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A001e")) { - NextTest(); - return; - } - err = TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 33: Test Harness Client reads EndpointList from Server DUT\n"); - if (ShouldSkip("PS.S.A001f")) { - NextTest(); - return; - } - err = TestStep33TestHarnessClientReadsEndpointListFromServerDut_32(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 33; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsStatusFromServerDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("status", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3TestHarnessClientReadsOrderFromServerDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOrderWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Error: %@", err); - } else { - NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("order", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("order", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("order", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsOrderFromServerDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("description", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("description", value, 60)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedInputVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Error: %@", err); - } else { - NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedInputVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputVoltage", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedInputFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Error: %@", err); - } else { - NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedInputFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputFrequency", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredCurrentTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Error: %@", err); - } else { - NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredCurrentType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("wiredCurrentType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiredCurrentType", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Error: %@", err); - } else { - NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedCurrent", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredNominalVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Error: %@", err); - } else { - NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredNominalVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredNominalVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredNominalVoltage", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredMaximumCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredMaximumCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredMaximumCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredMaximumCurrent", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredPresent", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveWiredFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeWiredFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeWiredFaults", value, 8)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batVoltage", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatPercentRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batPercentRemaining", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("batPercentRemaining", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batPercentRemaining", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatTimeRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batTimeRemaining", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batTimeRemaining", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batTimeRemaining", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargeLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batChargeLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batChargeLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batChargeLevel", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplacementNeededWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplacementNeeded", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplaceabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplaceability", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batReplaceability", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batReplaceability", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19TestHarnessClientReadsBatPresentFromServerDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batPresent", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveBatFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeBatFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeBatFaults", value, 8)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplacementDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplacementDescription", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batReplacementDescription", value, 60)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatCommonDesignationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batCommonDesignation", "enum16", "enum16")); - VerifyOrReturn(CheckConstraintMinValue("batCommonDesignation", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batCommonDesignation", [value unsignedShortValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatANSIDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batANSIDesignation", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batANSIDesignation", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatIECDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batIECDesignation", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batIECDesignation", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatApprovedChemistryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batApprovedChemistry", "enum16", "enum16")); - VerifyOrReturn(CheckConstraintMinValue("batApprovedChemistry", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batApprovedChemistry", [value unsignedShortValue], 32U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batCapacity", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batCapacity", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batCapacity", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatQuantityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batQuantity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("batQuantity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batQuantity", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batChargeState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batChargeState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batChargeState", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatTimeToFullChargeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batTimeToFullCharge", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batTimeToFullCharge", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batTimeToFullCharge", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatFunctionalWhileChargingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batFunctionalWhileCharging", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargingCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batChargingCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batChargingCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batChargingCurrent", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveBatChargeFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeBatChargeFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeBatChargeFaults", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep33TestHarnessClientReadsEndpointListFromServerDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndpointListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endpointList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_1_1() - : TestCommandBridge("Test_TC_PRS_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !PRS.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PRS.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0010")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0011")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0012")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads the optional attribute(Scale) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0014")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4f: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0003")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0013")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_2_1() - : TestCommandBridge("Test_TC_PRS_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the Tolerance attribute.\n"); - if (ShouldSkip("PRS.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheToleranceAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MinScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0011")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MaxScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0012")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the ScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0010")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheScaledValueAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the ScaledTolerance attribute.\n"); - if (ShouldSkip("PRS.S.A0013")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the Scale attribute.\n"); - if (ShouldSkip("PRS.S.A0014")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheScaleAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheToleranceAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MinScaledValueValue; - - CHIP_ERROR TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minScaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minScaledValue", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("minScaledValue", [value shortValue], 32766)); - } - { - MinScaledValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxScaledValueValue; - - CHIP_ERROR TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxScaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxScaledValue", [value shortValue], MinScaledValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxScaledValue", [value shortValue], 32767)); - } - { - MaxScaledValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheScaledValueAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("scaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("scaledValue", [value shortValue], MinScaledValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("scaledValue", [value shortValue], MaxScaledValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaledToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scaledTolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("scaledTolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("scaledTolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheScaleAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scale", "int8s", "int8s")); - VerifyOrReturn(CheckConstraintMinValue("scale", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("scale", [value charValue], 127)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_2_2() - : TestCommandBridge("Test_TC_PRS_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MeasuredValue attribute\n"); - if (ShouldSkip("PRS.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Operate on device to change the pressure significantly\n"); - if (ShouldSkip("PICS_USER_PROMPT && PRS.M.PressureChange")) { - NextTest(); - return; - } - err = TestStep3OperateOnDeviceToChangeThePressureSignificantly_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait 2s\n"); - err = TestWait2s_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute\n"); - if (ShouldSkip("PRS.S.A0000 && PRS.M.PressureChange")) { - NextTest(); - return; - } - err = TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable ValueBeforeChange; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ValueBeforeChange = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3OperateOnDeviceToChangeThePressureSignificantly_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait2s_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Error: %@", err); - } else { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("measuredValue", value, ValueBeforeChange)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_1_1() - : TestCommandBridge("Test_TC_PCC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !PCC.S.F00 && !PCC.S.F01 && !PCC.S.F02 && !PCC.S.F03 && !PCC.S.F04 && !PCC.S.F05 && !PCC.S.F06 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F06")) { - NextTest(); - return; - } - err = TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0005")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0006")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0009")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000a")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000b")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000c")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0014")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0016")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PCC.S.E00 && !PCC.S.E01 && !PCC.S.E02 && !PCC.S.E03 && !PCC.S.E04 && !PCC.S.E05 && !PCC.S.E06 && !PCC.S.E07 && !PCC.S.E08 && !PCC.S.E09 && !PCC.S.E0a && !PCC.S.E0b && !PCC.S.E0c && !PCC.S.E0d && !PCC.S.E0e && !PCC.S.E0f && !PCC.S.E10 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5b: TH reads from the DUT the EventList optional (SupplyVoltageLow)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5c: TH reads from the DUT the EventList optional (SupplyVoltageHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5d: TH reads from the DUT the EventList optional (PowerMissingPhase)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E02")) { - NextTest(); - return; - } - NextTest(); - return; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5e: TH reads from the DUT the EventList optional (SystemPressureLow)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E03")) { - NextTest(); - return; - } - NextTest(); - return; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5f: TH reads from the DUT the EventList optional (SystemPressureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E04")) { - NextTest(); - return; - } - NextTest(); - return; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5g: TH reads from the DUT the EventList optional (DryRunning)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E05")) { - NextTest(); - return; - } - NextTest(); - return; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5h: TH reads from the DUT the EventList optional (MotorTemperatureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E06")) { - NextTest(); - return; - } - NextTest(); - return; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5i: TH reads from the DUT the EventList optional (PumpMotorFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E07")) { - NextTest(); - return; - } - NextTest(); - return; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5j: TH reads from the DUT the EventList optional (ElectronicTemperatureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E08")) { - NextTest(); - return; - } - NextTest(); - return; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5k: TH reads from the DUT the EventList optional (PumpBlocked)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E09")) { - NextTest(); - return; - } - NextTest(); - return; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5l: TH reads from the DUT the EventList optional (SensorFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0a")) { - NextTest(); - return; - } - NextTest(); - return; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5m: TH reads from the DUT the EventList optional (ElectronicNonFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0b")) { - NextTest(); - return; - } - NextTest(); - return; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 5n: TH reads from the DUT the EventList optional (ElectronicFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0c")) { - NextTest(); - return; - } - NextTest(); - return; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5o: TH reads from the DUT the EventList optional (GeneralFault)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0d")) { - NextTest(); - return; - } - NextTest(); - return; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5p: TH reads from the DUT the EventList optional (Leakage)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0e")) { - NextTest(); - return; - } - NextTest(); - return; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5q: TH reads from the DUT the EventList optional (AirDetection)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0f")) { - NextTest(); - return; - } - NextTest(); - return; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5r: TH reads from the DUT the EventList optional (TurbineOperation)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E10")) { - NextTest(); - return; - } - NextTest(); - return; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 48; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_1() - : TestCommandBridge("Test_TC_PCC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MaxPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxFlow attribute.\n"); - if (ShouldSkip("PCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the MinConstPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MaxConstPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MinCompPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the MaxCompPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MinConstSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MaxConstSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the MinConstFlow attribute.\n"); - if (ShouldSkip("PCC.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the MaxConstFlow attribute.\n"); - if (ShouldSkip("PCC.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the MinConstTemp attribute.\n"); - if (ShouldSkip("PCC.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the MaxConstTemp attribute.\n"); - if (ShouldSkip("PCC.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the PumpStatus attribute.\n"); - if (ShouldSkip("PCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep15ThReadsFromTheDutThePumpStatusAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the EffectiveOperationMode attribute.\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the Capacity attribute.\n"); - if (ShouldSkip("PCC.S.A0013")) { - NextTest(); - return; - } - err = TestStep18ThReadsFromTheDutTheCapacityAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH reads from the DUT the Speed attribute.\n"); - if (ShouldSkip("PCC.S.A0014")) { - NextTest(); - return; - } - err = TestStep19ThReadsFromTheDutTheSpeedAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: TH reads from the DUT the Power attribute.\n"); - if (ShouldSkip("PCC.S.A0016")) { - NextTest(); - return; - } - err = TestStep21ThReadsFromTheDutThePowerAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: TH reads from the DUT the OperationMode attribute.\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep23ThReadsFromTheDutTheOperationModeAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: TH reads from the DUT the ControlMode attribute.\n"); - if (ShouldSkip("PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep24ThReadsFromTheDutTheControlModeAttribute_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minConstPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minConstPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxConstPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minCompPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minCompPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minCompPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxCompPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxCompPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxCompPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minConstSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minConstSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxConstSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minConstFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minConstFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxConstFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstTemp", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minConstTemp", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minConstTemp", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstTemp", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxConstTemp", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstTemp", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThReadsFromTheDutThePumpStatusAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePumpStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Error: %@", err); - } else { - NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("pumpStatus", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("pumpStatus", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("pumpStatus", [value unsignedShortValue], 8U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("effectiveOperationMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("effectiveOperationMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("effectiveOperationMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("effectiveControlMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("effectiveControlMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("effectiveControlMode", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThReadsFromTheDutTheCapacityAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Error: %@", err); - } else { - NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("capacity", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("capacity", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("capacity", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThReadsFromTheDutTheSpeedAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Error: %@", err); - } else { - NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("speed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("speed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lifetimeRunningHours", "int24u", "int24u")); - VerifyOrReturn(CheckConstraintMinValue("lifetimeRunningHours", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("lifetimeRunningHours", [value unsignedIntValue], 16777215UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThReadsFromTheDutThePowerAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Error: %@", err); - } else { - NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("power", "int24u", "int24u")); - VerifyOrReturn(CheckConstraintMinValue("power", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("power", [value unsignedIntValue], 16777215UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lifetimeEnergyConsumed", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("lifetimeEnergyConsumed", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("lifetimeEnergyConsumed", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThReadsFromTheDutTheOperationModeAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("operationMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("operationMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24ThReadsFromTheDutTheControlModeAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("controlMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("controlMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("controlMode", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_2() - : TestCommandBridge("Test_TC_PCC_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.F06 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F06 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_3() - : TestCommandBridge("Test_TC_PCC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F00 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F00 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F01 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F01 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F02 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F02 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F04 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F04 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F05 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F05 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_4() - : TestCommandBridge("Test_TC_PCC_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:2UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:3UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:2UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:3UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_REFALM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_REFALM_1_1() - : TestCommandBridge("Test_TC_REFALM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_REFALM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_REFALM_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_REFALM_2_1() - : TestCommandBridge("Test_TC_REFALM_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_REFALM_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Ensure that the door alarm is not locally suppressed and the door is closed\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the Mask attribute\n"); - if (ShouldSkip("REFALM.S.A0000")) { - NextTest(); - return; - } - err = TestStep3thReadsFromTheDutTheMaskAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the State attribute\n"); - if (ShouldSkip("REFALM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4thReadsFromTheDutTheStateAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5:TH reads from the DUT the Supportedask attribute\n"); - if (ShouldSkip("REFALM.S.A0003")) { - NextTest(); - return; - } - err = TestStep5thReadsFromTheDutTheSupportedaskAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3thReadsFromTheDutTheMaskAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Error: %@", err); - } else { - NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("mask", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thReadsFromTheDutTheStateAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH reads from the DUT the State attribute: Error: %@", err); - } else { - NSLog(@"Step 4:TH reads from the DUT the State attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("state", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5thReadsFromTheDutTheSupportedaskAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Error: %@", err); - } else { - NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supported", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RH_1_1() - : TestCommandBridge("Test_TC_RH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); - err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("RH.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the AcceptedCommandList attribute from the DUT.\n"); - err = TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the GeneratedCommandList attribute from the DUT.\n"); - err = TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads the EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCCLEANM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCCLEANM_1_1() - : TestCommandBridge("Test_TC_RVCCLEANM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCCLEANM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCCLEANM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCCLEANM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !RVCCLEANM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RVCCLEANM.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenRvccleanmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT\n"); - if (ShouldSkip("RVCCLEANM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT\n"); - if (ShouldSkip(" !RVCCLEANM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); - if (ShouldSkip("RVCCLEANM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); - if (ShouldSkip("RVCCLEANM.S.C01.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenRvccleanmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCRUNM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCRUNM_1_1() - : TestCommandBridge("Test_TC_RVCRUNM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCRUNM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCRUNM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCRUNM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !RVCRUNM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RVCRUNM.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenRvcrunmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT\n"); - if (ShouldSkip("RVCRUNM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT\n"); - if (ShouldSkip(" !RVCRUNM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); - if (ShouldSkip("RVCRUNM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); - if (ShouldSkip("RVCRUNM.S.C01.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenRvcrunmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCOPSTATE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCOPSTATE_1_1() - : TestCommandBridge("Test_TC_RVCOPSTATE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCOPSTATE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCOPSTATE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCOPSTATE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); - if (ShouldSkip("RVCOPSTATE.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && RVCOPSTATE.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Pause) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Start) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C03.Rsp || RVCOPSTATE.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip(" !RVCOPSTATE.S.C00.Rsp && !RVCOPSTATE.S.C01.Rsp && !RVCOPSTATE.S.C02.Rsp && !RVCOPSTATE.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip(" RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp || RVCOPSTATE.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SMOKECO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SMOKECO_1_1() - : TestCommandBridge("Test_TC_SMOKECO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SMOKECO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip("!SMOKECO.S.F00 && !SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F00 && !SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F01 && !SMOKECO.S.F00")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F00 && SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState)\n"); - if (ShouldSkip("SMOKECO.S.A0001 && SMOKECO.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads from the DUT the AttributeList attribute(COState)\n"); - if (ShouldSkip("SMOKECO.S.A0002 && SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted)\n"); - if (ShouldSkip("SMOKECO.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm)\n"); - if (ShouldSkip("SMOKECO.S.A0008")) { - NextTest(); - return; - } - err = TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm)\n"); - if (ShouldSkip("SMOKECO.S.A0009")) { - NextTest(); - return; - } - err = TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState)\n"); - if (ShouldSkip("SMOKECO.S.A000a")) { - NextTest(); - return; - } - err = TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel)\n"); - if (ShouldSkip("SMOKECO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate)\n"); - if (ShouldSkip("SMOKECO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads from the DUT the EventList attribute(SmokeAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads from the DUT the EventList attribute(COAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5d: TH reads from the DUT the EventList attribute(AlarmMuted)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E06")) { - NextTest(); - return; - } - NextTest(); - return; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5e: TH reads from the DUT the EventList attribute(MuteEnded)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E07")) { - NextTest(); - return; - } - NextTest(); - return; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5f: TH reads from the DUT the EventList attribute(InterconnectSmokeAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E08")) { - NextTest(); - return; - } - NextTest(); - return; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5g: TH reads from the DUT the EventList attribute(InterconnectCOAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E09")) { - NextTest(); - return; - } - NextTest(); - return; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("!SMOKECO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6b: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("SMOKECO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 3UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SMOKECO_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SMOKECO_2_1() - : TestCommandBridge("Test_TC_SMOKECO_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SMOKECO_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ExpressedState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SmokeState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the COState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheCOStateAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the BatteryAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the DeviceMuted attribute\n"); - if (ShouldSkip("SMOKECO.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the TestInProgress attribute\n"); - if (ShouldSkip("SMOKECO.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the HardwareFaultAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the EndOfServiceAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute\n"); - if (ShouldSkip("SMOKECO.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the InterconnectCOAlarm attribute\n"); - if (ShouldSkip("SMOKECO.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the ContaminationState attribute\n"); - if (ShouldSkip("SMOKECO.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute\n"); - if (ShouldSkip("SMOKECO.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the ExpiryDate attribute\n"); - if (ShouldSkip("SMOKECO.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeExpressedStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("expressedState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("expressedState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("expressedState", [value unsignedCharValue], 8U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSmokeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("smokeState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("smokeState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("smokeState", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheCOStateAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCOStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the COState attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the COState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("COState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("COState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("COState", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatteryAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batteryAlert", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batteryAlert", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batteryAlert", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceMutedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("deviceMuted", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("deviceMuted", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("deviceMuted", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTestInProgressWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("testInProgress", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHardwareFaultAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("hardwareFaultAlert", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndOfServiceAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endOfServiceAlert", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endOfServiceAlert", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endOfServiceAlert", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInterconnectSmokeAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("interconnectSmokeAlarm", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("interconnectSmokeAlarm", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("interconnectSmokeAlarm", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInterconnectCOAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("interconnectCOAlarm", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("interconnectCOAlarm", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("interconnectCOAlarm", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeContaminationStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("contaminationState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("contaminationState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("contaminationState", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSmokeSensitivityLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("smokeSensitivityLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("smokeSensitivityLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("smokeSensitivityLevel", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeExpiryDateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("expiryDate", "epoch_s", "epoch_s")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SWTCH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SWTCH_1_1() - : TestCommandBridge("Test_TC_SWTCH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SWTCH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SWTCH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SWTCH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 3: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep3ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads from the DUT the FeatureMap attribute and Check values of flags in this FeatureMap\n"); - if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep2aThReadsFromTheDutTheFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F02")) { - NextTest(); - return; - } - err = TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F03")) { - NextTest(); - return; - } - err = TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: TH reads EventList if SWTCH.S.F00(LS)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: TH reads EventList if SWTCH.S.F01(MS) & !SWTCH.S.F02(MSR)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && !SWTCH.S.F02")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5e: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5f: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5g: TH reads EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsFromTheDutTheFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads from the DUT the FeatureMap attribute and Check values of flags in this FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads from the DUT the FeatureMap attribute and Check values of flags in this FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCCM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCCM_1_1() - : TestCommandBridge("Test_TC_TCCM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCCM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCCM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCCM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode)\n"); - if (ShouldSkip("TCCM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_1_1() - : TestCommandBridge("Test_TC_TCTL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip("!TCTL.S.F00 && !TCTL.S.F01 && !TCTL.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL)\n"); - if (ShouldSkip("TCTL.S.F00 && !TCTL.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F01 && !TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F02 && TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP)\n"); - if (ShouldSkip("TCTL.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL)\n"); - if (ShouldSkip("TCTL.S.F01")) { - NextTest(); - return; - } - err = TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_2_2() - : TestCommandBridge("Test_TC_TCTL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull MinTemperatureValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); - { - MinTemperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxTemperatureValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); - VerifyOrReturn(CheckConstraintMinValue("maxTemperature", [value shortValue], MinTemperatureValue)); - { - MaxTemperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull temperatureValue; - - CHIP_ERROR TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("temperatureSetpoint", [value shortValue], MinTemperatureValue)); - VerifyOrReturn(CheckConstraintMaxValue("temperatureSetpoint", [value shortValue], MaxTemperatureValue)); - { - temperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_2_3() - : TestCommandBridge("Test_TC_TCTL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); - if (ShouldSkip("TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a list of strings with each string length not exceeding 16 characters.\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("selectedTemperatureLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("selectedTemperatureLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("selectedTemperatureLevel", [value unsignedCharValue], 31U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedTemperatureLevels", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_TCTL_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_3_2() - : TestCommandBridge("Test_TC_TCTL_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step_5_setTemp", INT16_MIN, INT16_MAX, &mStep5SetTemp); - AddArgument("InvalidTemp", INT16_MIN, INT16_MAX, &mInvalidTemp); - AddArgument("Step_10_setTemp", INT16_MIN, INT16_MAX, &mStep10SetTemp); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature number can be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MinTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for 5s\n"); - err = TestWaitFor5s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); - err = TestWaitFor5s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: Operate device such that a temperature number cannot be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for 5s\n"); - err = TestWaitFor5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 11: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000 && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep5SetTemp; - chip::Optional mInvalidTemp; - chip::Optional mStep10SetTemp; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull minTemp; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); - { - minTemp = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull maxTemp; - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); - { - maxTemp = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mStep5SetTemp.HasValue() ? [NSNumber numberWithShort:mStep5SetTemp.Value()] : [NSNumber numberWithShort:5]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mInvalidTemp.HasValue() ? [NSNumber numberWithShort:mInvalidTemp.Value()] : [NSNumber numberWithShort:100]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mStep10SetTemp.HasValue() ? [NSNumber numberWithShort:mStep10SetTemp.Value()] : [NSNumber numberWithShort:50]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_3_3() - : TestCommandBridge("Test_TC_TCTL_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step_4_setLevel", 0, UINT8_MAX, &mStep4SetLevel); - AddArgument("Step_7_setLevel", 0, UINT8_MAX, &mStep7SetLevel); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature level can be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); - if (ShouldSkip("TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 5s\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestWaitFor5s_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004 && TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6:Operate device such that a temperature level cannot be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestWaitFor5s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004 && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep4SetLevel; - chip::Optional mStep7SetLevel; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSArray * _Nonnull supportedLevels; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); - { - supportedLevels = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = mStep4SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep4SetLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = mStep7SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep7SetLevel.Value()] : [NSNumber numberWithUnsignedChar:3U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TMP_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TMP_1_1() - : TestCommandBridge("Test_TC_TMP_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TMP_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from the DUT\n"); - err = TestStep3ThReadsFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("TMP.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads AcceptedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads GeneratedCommandList attribute from the DUT\n"); - err = TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TMP_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TMP_2_1() - : TestCommandBridge("Test_TC_TMP_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TMP_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the MinMeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the MaxMeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the MeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable CurrentMinMeasured; - - CHIP_ERROR TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -27315)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); - } - { - CurrentMinMeasured = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable CurrentMaxMeasured; - - CHIP_ERROR TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], CurrentMinMeasured)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); - } - { - CurrentMaxMeasured = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], CurrentMinMeasured)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], CurrentMaxMeasured)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSTAT_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSTAT_1_1() - : TestCommandBridge("Test_TC_TSTAT_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSTAT_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSTAT_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSTAT_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!TSTAT.S.F00 && !TSTAT.S.F01 && !TSTAT.S.F02 && !TSTAT.S.F03 && !TSTAT.S.F04 && !TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F06")) { - NextTest(); - return; - } - err = TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: TH reads the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: TH reads the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: TH reads the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: TH reads the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: TH reads the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: TH reads the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F04")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: TH reads the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F04 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0001")) { - NextTest(); - return; - } - err = TestStep4kThReadsTheOptionalAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0009")) { - NextTest(); - return; - } - err = TestStep4lThReadsTheOptionalAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0010")) { - NextTest(); - return; - } - err = TestStep4mThReadsTheOptionalAttributeInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A001a")) { - NextTest(); - return; - } - err = TestStep4nThReadsTheOptionalAttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A001d")) { - NextTest(); - return; - } - err = TestStep4oThReadsTheOptionalAttributeInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0023")) { - NextTest(); - return; - } - err = TestStep4pThReadsTheOptionalAttributeInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0024")) { - NextTest(); - return; - } - err = TestStep4qThReadsTheOptionalAttributeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4r: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0025")) { - NextTest(); - return; - } - err = TestStep4rThReadsTheOptionalAttributeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4s: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0029")) { - NextTest(); - return; - } - err = TestStep4sThReadsTheOptionalAttributeInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4t: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0030")) { - NextTest(); - return; - } - err = TestStep4tThReadsTheOptionalAttributeInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4u: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0031")) { - NextTest(); - return; - } - err = TestStep4uThReadsTheOptionalAttributeInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0032")) { - NextTest(); - return; - } - err = TestStep4xThReadsTheOptionalAttributeInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4y: TH reads the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A003a")) { - NextTest(); - return; - } - err = TestStep4yThReadsTheOptionalAttributeAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0040")) { - NextTest(); - return; - } - err = TestStep4zThReadsTheOptionalAttributeInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4A: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0041")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOptionalAttributeInAttributeList_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4B: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0042")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeInAttributeList_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4C: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0043")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInAttributeList_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 4D: TH reads the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0044")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeAttributeList_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4E: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0045")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeInAttributeList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4F: TH reads the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0046")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributeInAttributeList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 4g: TH reads the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0047")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeAttributeList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4H: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0003")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4I: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0004")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4J: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0008")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4K: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0015")) { - NextTest(); - return; - } - err = TestStep4kThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4L: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0016")) { - NextTest(); - return; - } - err = TestStep4lThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4M: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0005")) { - NextTest(); - return; - } - err = TestStep4mThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4N: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { - NextTest(); - return; - } - err = TestStep4nThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4O: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { - NextTest(); - return; - } - err = TestStep4oThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4P: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0017")) { - NextTest(); - return; - } - err = TestStep4pThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4Q: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0018")) { - NextTest(); - return; - } - err = TestStep4qThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4R: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F05 && TSTAT.S.A001e")) { - NextTest(); - return; - } - err = TestStep4rThReadsTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5: TH reads EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 6b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 6c: TH reads the optional (GetRelayStatusLog) command in AcceptedCommandList\n"); - if (ShouldSkip("TSTAT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute.\n"); - if (ShouldSkip(" !TSTAT.S.C04.Rsp && !TSTAT.S.C02.Rsp ")) { - NextTest(); - return; - } - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 7b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep7bThReadsFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Step 7c: TH reads optional command (GetRelayStatusLogResponse) in GeneratedCommandList\n"); - if (ShouldSkip("TSTAT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep7cThReadsOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_59(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 60; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsTheOptionalAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsTheOptionalAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsTheOptionalAttributeInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsTheOptionalAttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsTheOptionalAttributeInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsTheOptionalAttributeInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsTheOptionalAttributeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsTheOptionalAttributeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsTheOptionalAttributeInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsTheOptionalAttributeInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4uThReadsTheOptionalAttributeInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4u: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4u: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4xThReadsTheOptionalAttributeInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4x: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4x: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4yThReadsTheOptionalAttributeAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4y: TH reads the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4y: TH reads the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4zThReadsTheOptionalAttributeInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4z: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4z: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheOptionalAttributeInAttributeList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4A: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4A: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeInAttributeList_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4B: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4B: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInAttributeList_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4C: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4C: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 67UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeAttributeList_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4D: TH reads the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4D: TH reads the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 68UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeInAttributeList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4E: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4E: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 69UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributeInAttributeList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4F: TH reads the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4F: TH reads the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 70UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeAttributeList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 71UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4H: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4H: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4I: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4I: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4J: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4J: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4K: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4K: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4L: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4L: TH reads the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4M: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4M: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4N: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4N: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4O: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4O: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4P: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4P: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4Q: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4Q: TH reads the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4R: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4R: TH reads the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional (GetRelayStatusLog) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional (GetRelayStatusLog) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7cThReadsOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7c: TH reads optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7c: TH reads optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_1_1() - : TestCommandBridge("Test_TC_TSUIC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_2_1() - : TestCommandBridge("Test_TC_TSUIC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the TemperatureDisplayMode attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the KeypadLockout attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("temperatureDisplayMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("temperatureDisplayMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("temperatureDisplayMode", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("keypadLockout", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("keypadLockout", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("keypadLockout", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scheduleProgrammingVisibility", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("scheduleProgrammingVisibility", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("scheduleProgrammingVisibility", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_2_2() - : TestCommandBridge("Test_TC_TSUIC_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify device temperature displayed in °C\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestVerifyDeviceTemperatureDisplayedInc_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Verify device temperature displayed in °F\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestVerifyDeviceTemperatureDisplayedInf_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2d: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2f: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify all device functionality available to the user\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyAllDeviceFunctionalityAvailableToTheUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Verify device operates at Level 1 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify device operates at Level 2 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Verify device operates at Level 3 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3h: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Verify device operates at Level 4 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3j: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Verify device operates at least functionality level\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3l: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 3n: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Verify local schedule programming functionality is enabled at the thermostat\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Verify local schedule programming functionality is disabled at the thermostat\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 37; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInc_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInf_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyAllDeviceFunctionalityAvailableToTheUser_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:6U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGTHREAD_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGTHREAD_1_1() - : TestCommandBridge("Test_TC_DGTHREAD_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGTHREAD_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGTHREAD_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGTHREAD_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.F00 && !DGTHREAD.S.F01 && !DGTHREAD.S.F02 && !DGTHREAD.S.F03 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0006 && DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.F03")) { - NextTest(); - return; - } - err = TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0038")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0039")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4g: TH reads the optional attribute (Delay) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A003a")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.E00 && !DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads DGTHREAD.S.E00(ConnectionStatus) event in EventList\n"); - if (ShouldSkip("DGTHREAD.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads DGTHREAD.S.E01(NetworkFaultChange) event in EventList\n"); - if (ShouldSkip("DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 45UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 46UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 47UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TIMESYNC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TIMESYNC_1_1() - : TestCommandBridge("Test_TC_TIMESYNC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TIMESYNC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Check for optional attribute TimeSource in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4d: Check for optional attribute TimeSource not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4e: Check for TZ feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4f: Check for TZ feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4g: Check for NTPC feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4h: Check for NTPC feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4i: Check for NTPS feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4j: Check for NTPS feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4k: Check for TSC feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4l: Check for TSC feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5b: Check for TZ feature-based events in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5c: Check for TZ feature-based events not in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5d: Check for TSC feature-based events in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F03")) { - NextTest(); - return; - } - NextTest(); - return; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5e: Check for TSC feature-based events not in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F03")) { - NextTest(); - return; - } - NextTest(); - return; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6b: Check for TZ feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6c: Check for TZ feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 6d: Check for NTPC feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 6f: Check for TSC feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 6g: Check for TSC feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 7b: Check for TZ feature-based commands in not GeneratedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 36; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TIMESYNC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TIMESYNC_2_3() - : TestCommandBridge("Test_TC_TIMESYNC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TIMESYNC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read commissioner nodeID and saves as th_node_id\n"); - err = TestReadCommissionerNodeIDAndSavesAsThNodeId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0\n"); - err = TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx\n"); - err = TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the TrustedTimeSource attribute.\n"); - err = TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.\n"); - err = TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the TrustedTimeSource attribute.\n"); - err = TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th_node_id; - - CHIP_ERROR TestReadCommissionerNodeIDAndSavesAsThNodeId_1() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - th_node_id = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; - params.trustedTimeSource = [[MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct alloc] init]; - ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).nodeID = - [th_node_id copy]; - ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster setTrustedTimeSourceWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull th_fabric_idx; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th_fabric_idx = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TrustedTimeSource", actualValue)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).fabricIndex, th_fabric_idx)); - VerifyOrReturn(CheckValue("NodeID", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).nodeID, th_node_id)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).endpoint, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; - params.trustedTimeSource = nil; - [cluster setTrustedTimeSourceWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("TrustedTimeSource", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_1_1() - : TestCommandBridge("Test_TC_ULABEL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_1() - : TestCommandBridge("Test_TC_ULABEL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads LabelList from the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsLabelListFromTheDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsLabelListFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads LabelList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads LabelList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_2() - : TestCommandBridge("Test_TC_ULABEL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"roomName"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"master bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"roomType"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"bedroom"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"roomName")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"master bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"roomType")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"bedroom")); - } - - VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("labelList", value, 4)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_3() - : TestCommandBridge("Test_TC_ULABEL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"17_bytesIsTooLongforuserlabelnotexpected"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"17_bytesIsTooLongforuserlabelnotexpected"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"foobar"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Error: %@", err); - } else { - NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_4() - : TestCommandBridge("Test_TC_ULABEL_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' \n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsLabelListAttributeOfTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @""; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @""; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Error: %@", err); - } else { - NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsLabelListAttributeOfTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_1_1() - : TestCommandBridge("Test_TC_DGWIFI_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip("( !DGWIFI.S.F00 && !DGWIFI.S.F01 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGWIFI.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.A000b")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGWIFI.S.E00 && !DGWIFI.S.E01 && !DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads optional attribute (Disconnection) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5c: TH reads optional attribute (AssociationFailure) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: TH reads optional attribute (ConnectionStatus) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGWIFI.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_2_1() - : TestCommandBridge("Test_TC_DGWIFI_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads BSSID attribute from DUT\n"); - if (ShouldSkip("DGWIFI.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsBssidAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads SecurityType attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsSecurityTypeAttributeConstraints_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads WiFiVersion attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsWiFiVersionAttributeConstraints_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads ChannelNumber attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsChannelNumberAttributeConstraints_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads RSSI attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsRssiAttributeConstraints_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads BeaconLostCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsBeaconLostCountAttributeConstraints_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads BeaconRxCount attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsBeaconRxCountAttributeConstraints_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads PacketMulticastRxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads PacketMulticastTxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads PacketUnicastRxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads PacketUnicastTxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads CurrentMaxRate attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsCurrentMaxRateAttributeConstraints_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads OverrunCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsOverrunCountAttributeConstraints_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsBssidAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBSSIDWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads BSSID attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads BSSID attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("bssid", "octet_string", "octet_string")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsSecurityTypeAttributeConstraints_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSecurityTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads SecurityType attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads SecurityType attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("securityType", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsWiFiVersionAttributeConstraints_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiFiVersionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiFiVersion", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("wiFiVersion", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiFiVersion", [value unsignedCharValue], 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsChannelNumberAttributeConstraints_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelNumberWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("channelNumber", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("channelNumber", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("channelNumber", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsRssiAttributeConstraints_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRSSIWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads RSSI attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads RSSI attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("rssi", "int8s", "int8s")); - VerifyOrReturn(CheckConstraintMinValue("rssi", [value charValue], -120)); - VerifyOrReturn(CheckConstraintMaxValue("rssi", [value charValue], 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsBeaconLostCountAttributeConstraints_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsBeaconRxCountAttributeConstraints_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsCurrentMaxRateAttributeConstraints_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentMaxRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentMaxRate", "int64u", "int64u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsOverrunCountAttributeConstraints_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_2_3() - : TestCommandBridge("Test_TC_DGWIFI_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TWait for the commissioned device to be retrieved\n"); - err = TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends ResetCounts command to DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsResetCountsCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads BeaconLostCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0005")) { - NextTest(); - return; - } - err = TestStep2aThReadsBeaconLostCountAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads BeaconRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0006")) { - NextTest(); - return; - } - err = TestStep2bThReadsBeaconRxCountAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH reads PacketMulticastRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0007")) { - NextTest(); - return; - } - err = TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: TH reads PacketMulticastTxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0008")) { - NextTest(); - return; - } - err = TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: TH reads PacketUnicastRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0009")) { - NextTest(); - return; - } - err = TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: TH reads PacketUnicastTxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A000a")) { - NextTest(); - return; - } - err = TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsResetCountsCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resetCountsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends ResetCounts command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends ResetCounts command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsBeaconLostCountAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsBeaconRxCountAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_1_1() - : TestCommandBridge("Test_TC_WNCV_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - if (ShouldSkip("!WNCV.S.F00 && !WNCV.S.F01 && !WNCV.S.F02 && !WNCV.S.F03 && !WNCV.S.F04 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList\n"); - if (ShouldSkip("WNCV.S.A001a")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); - err = TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("clusterRevision", [value unsignedShortValue], 5U)); - VerifyOrReturn(CheckConstraintMaxValue("clusterRevision", [value unsignedShortValue], 200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_1() - : TestCommandBridge("Test_TC_WNCV_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads from the DUT the ( 0) Type attribute\n"); - if (ShouldSkip("WNCV.S.A0000")) { - NextTest(); - return; - } - err = TestStep1aThReadsFromTheDutThe0TypeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute\n"); - if (ShouldSkip("WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads from the DUT the (13) EndProductType attribute\n"); - if (ShouldSkip("WNCV.S.A000d")) { - NextTest(); - return; - } - err = TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads from the DUT the (23) Mode attribute\n"); - if (ShouldSkip("WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1eThReadsFromTheDutThe23ModeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH writes to (23) Mode attribute the value 0\n"); - if (ShouldSkip("WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1fThWritesTo23ModeAttributeTheValue0_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0010")) { - NextTest(); - return; - } - err = TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0012")) { - NextTest(); - return; - } - err = TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH reads from the DUT the (26) SafetyStatus attribute\n"); - if (ShouldSkip("WNCV.S.A001a")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0002")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute\n"); - if (ShouldSkip("WNCV.S.A0003 && !WNCV.S.A0010 && !WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3d: TH reads the RO optional attribute default: CurrentPositionLift\n"); - if (ShouldSkip("WNCV.S.A0003 && WNCV.S.A0010 && WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0004 && !WNCV.S.A0012 && !WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt\n"); - if (ShouldSkip("WNCV.S.A0004 && WNCV.S.A0012 && WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute\n"); - if (ShouldSkip("WNCV.S.A0005")) { - NextTest(); - return; - } - err = TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0006")) { - NextTest(); - return; - } - err = TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute\n"); - if (ShouldSkip("WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute\n"); - if (ShouldSkip("WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsFromTheDutThe0TypeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("type", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("type", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("type", [value unsignedCharValue], 9U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("operationalStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("operationalStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsFromTheDutThe23ModeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("mode", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 15U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThWritesTo23ModeAttributeTheValue0_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Error: %@", err); - } else { - NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledOpenLimitLiftValue; - - CHIP_ERROR TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledOpenLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedOpenLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitLift", [value unsignedShortValue], 65535U)); - { - InstalledOpenLimitLiftValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledClosedLimitLiftValue; - - CHIP_ERROR TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedClosedLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitLift", [value unsignedShortValue], 65535U)); - { - InstalledClosedLimitLiftValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledOpenLimitTiltValue; - - CHIP_ERROR TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledOpenLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedOpenLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitTilt", [value unsignedShortValue], 65535U)); - { - InstalledOpenLimitTiltValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledClosedLimitTiltValue; - - CHIP_ERROR TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedClosedLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitTilt", [value unsignedShortValue], 65535U)); - { - InstalledClosedLimitTiltValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSafetyStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("safetyStatus", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("safetyStatus", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("safetyStatus", [value unsignedShortValue], 2047U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalClosedLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitLift", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalClosedLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitTilt", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], InstalledOpenLimitLiftValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], InstalledClosedLimitLiftValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], InstalledOpenLimitTiltValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], InstalledClosedLimitTiltValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfActuationsLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfActuationsLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsLift", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfActuationsTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfActuationsTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsTilt", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Error: %@", err); - } else { - NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Error: %@", err); - } else { - NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_2() - : TestCommandBridge("Test_TC_WNCV_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); - if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); - if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F00 && !WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); - if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); - if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F01 && !WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational)\n"); - if (ShouldSkip("WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_3() - : TestCommandBridge("Test_TC_WNCV_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step Wait for the commissioned device to be retrieved\n"); - err = TestStepWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH set the Mode Attribute bit0 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1aThSetTheModeAttributeBit0OfTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1bThReadsConfigStatusAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH clear the Mode Attribute bit0 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1cThClearTheModeAttributeBit0OfTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1dThReadsConfigStatusAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH set the Mode Attribute bit1 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2aThSetTheModeAttributeBit1OfTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep2bThReadsConfigStatusAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2d: TH clear the Mode Attribute bit1 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2dThClearTheModeAttributeBit1OfTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep2eThReadsConfigStatusAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2f: TH reads the Mode Attribute from the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2fThReadsTheModeAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2g: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2gThSendDownOrCloseCommandToTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH set the Mode Attribute bit2 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep3aThSetTheModeAttributeBit2OfTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendDownOrCloseCommandToTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep3cThReadsConfigStatusAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH clear the Mode Attribute bit2 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep3dThClearTheModeAttributeBit2OfTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3e: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3eThSendDownOrCloseCommandToTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep3fThReadsConfigStatusAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_BUSY)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStepWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSetTheModeAttributeBit0OfTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThClearTheModeAttributeBit0OfTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSetTheModeAttributeBit1OfTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull configStatusValA; - - CHIP_ERROR TestStep2bThReadsConfigStatusAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - { - configStatusValA = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThClearTheModeAttributeBit1OfTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThReadsConfigStatusAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsTheModeAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2gThSendDownOrCloseCommandToTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSetTheModeAttributeBit2OfTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendDownOrCloseCommandToTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_BUSY)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull configStatusValB; - - CHIP_ERROR TestStep3cThReadsConfigStatusAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - { - configStatusValB = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThClearTheModeAttributeBit2OfTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThSendDownOrCloseCommandToTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsConfigStatusAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_5() - : TestCommandBridge("Test_TC_WNCV_2_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads EndProductType attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000d")) { - NextTest(); - return; - } - err = TestStep1ThReadsEndProductTypeAttributeFromDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsEndProductTypeAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_1() - : TestCommandBridge("Test_TC_WNCV_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); - AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); - AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); - AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); - AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 5 - 15 seconds movement(s) on the device\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsUpOrOpenCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH waits for 1-5 seconds movement(s) on the DUT\n"); - err = TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3aThReadsOperationalStatusAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: DUT updates its attributes\n"); - err = TestStep3aDutUpdatesItsAttributes_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStopMotionCommandToDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep4cThReadsOperationalStatusAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5a: TH waits for 100-1000 ms\n"); - err = TestStep5aThWaitsFor1001000Ms_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep1bWaitTime; - chip::Optional mStep2bWaitTime; - chip::Optional mStep2eWaitTime; - chip::Optional mStep4bWaitTime; - chip::Optional mStep5aWaitTime; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 200UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3aThReadsOperationalStatusAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aDutUpdatesItsAttributes_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsFor1001000Ms_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_2() - : TestCommandBridge("Test_TC_WNCV_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); - AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); - AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); - AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); - AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 10 seconds movement(s) on the device\n"); - err = TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends DownOrClose command to DUT\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsDownOrCloseCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH leave the device moving for 2 seconds\n"); - err = TestStep2eThLeaveTheDeviceMovingFor2Seconds_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3aThReadsOperationalStatusAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: DUT updates its attributes\n"); - err = TestStep3aDutUpdatesItsAttributes_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStopMotionCommandToDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep4cThReadsOperationalStatusAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5a: TH waits for 100-1000 ms\n"); - err = TestStep5aThWaitsFor1001000Ms_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep1bWaitTime; - chip::Optional mStep2bWaitTime; - chip::Optional mStep2eWaitTime; - chip::Optional mStep4bWaitTime; - chip::Optional mStep5aWaitTime; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 200UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThLeaveTheDeviceMovingFor2Seconds_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3aThReadsOperationalStatusAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aDutUpdatesItsAttributes_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsFor1001000Ms_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 200UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_3() - : TestCommandBridge("Test_TC_WNCV_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 6-8 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH waits for 1-5 seconds revert motion(s) on the DUT\n"); - err = TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep1eThReadsOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH waits for 2 seconds\n"); - err = TestStep1fThWaitsFor2Seconds_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); - err = TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); - err = TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAStopMotionCommandToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThReadsOperationalStatusAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH waits for 100ms - 3s attributes update on the device\n"); - err = TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2e: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2eThReadsOperationalStatusAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000c && WNCV.S.A000f && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1eThReadsOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("operationalStatus", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThWaitsFor2Seconds_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - bool testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = nil; - - CHIP_ERROR TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); - } else { - NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 4U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeOperationalStatusWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 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); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAStopMotionCommandToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsOperationalStatusAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsOperationalStatusAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionLift; - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionLift = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionLift == nil) { - VerifyOrReturn(CheckValueNull("TargetPositionLiftPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, attrCurrentPositionLift)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionTilt; - - CHIP_ERROR TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionTilt = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionTilt == nil) { - VerifyOrReturn(CheckValueNull("TargetPositionTiltPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, attrCurrentPositionTilt)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_4() - : TestCommandBridge("Test_TC_WNCV_3_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsUpOrOpenCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFastMotionDuration; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_5() - : TestCommandBridge("Test_TC_WNCV_3_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsUpOrOpenCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends DownOrClose command to DUT\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsDownOrCloseCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFastMotionDuration; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_1() - : TestCommandBridge("Test_TC_WNCV_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); - err = TestStep4bThWaitsFor1001000Ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep5bThChecksOperationalStatusAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:2500U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 2500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 2500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 25U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:7520U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 7520U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThChecksOperationalStatusAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 7520U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 75U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_2() - : TestCommandBridge("Test_TC_WNCV_4_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); - err = TestStep4bThWaitsFor1001000Ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep5bThReadsOperationalStatusAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:3000U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 3000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 3000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 30U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:6005U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 6005U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThReadsOperationalStatusAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 6005U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 60U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_3() - : TestCommandBridge("Test_TC_WNCV_4_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - 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. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; - - CHIP_ERROR TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionLiftPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Error: %@", err); - } else { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, [attrCurrentPositionLiftPercent100ths unsignedShortValue] / 100U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:12288U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:10001U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_4() - : TestCommandBridge("Test_TC_WNCV_4_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - 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. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; - - CHIP_ERROR TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionTiltPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Error: %@", err); - } else { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, [attrCurrentPositionTiltPercent100ths unsignedShortValue] / 100U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:12288U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:10001U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_5() - : TestCommandBridge("Test_TC_WNCV_4_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0a: Wait for the commissioned device to be retrieved\n"); - err = TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0b: TH sends UpOrOpen command to preposition the DUT\n"); - err = TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH Waits for 100ms-1s\n"); - err = TestStep1bThWaitsFor100ms1s_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1c: TH sends StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsStopMotionCommandToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1d: TH Waits for 100ms-1s\n"); - err = TestStep1dThWaitsFor100ms1s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH Waits for 100ms-1s\n"); - err = TestStep2bThWaitsFor100ms1s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH sends StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsStopMotionCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH Waits for 100ms-1s\n"); - err = TestStep2dThWaitsFor100ms1s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: reboot/restart the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3cRebootRestartTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStepRebootTargetDeviceDUT_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: Wait for the commissioned device to be retrieved\n"); - err = TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:9000U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor100ms1s_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cThSendsStopMotionCommandToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWaitsFor100ms1s_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:9000U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor100ms1s_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThSendsStopMotionCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThWaitsFor100ms1s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 500UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; - - CHIP_ERROR TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); - { - attrCurrentPositionLiftPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; - - CHIP_ERROR TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); - { - attrCurrentPositionTiltPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cRebootRestartTheDut_12() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStepRebootTargetDeviceDUT_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionLiftPercent100ths == nil) { - VerifyOrReturn(CheckValueNull("CurrentPositionLiftPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, attrCurrentPositionLiftPercent100ths)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionTiltPercent100ths == nil) { - VerifyOrReturn(CheckValueNull("CurrentPositionTiltPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, attrCurrentPositionTiltPercent100ths)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_TargetNavigatorCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_TargetNavigatorCluster() - : TestCommandBridge("TV_TargetNavigatorCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_TargetNavigatorCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_TargetNavigatorCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_TargetNavigatorCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Target Navigator list\n"); - err = TestReadAttributeTargetNavigatorList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current navigator target\n"); - err = TestReadAttributeCurrentNavigatorTarget_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Navigate Target Request Command\n"); - err = TestNavigateTargetRequestCommand_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeTargetNavigatorList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Target Navigator list: Error: %@", err); - } else { - NSLog(@"Read attribute Target Navigator list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TargetList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).identifier, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).name, @"exampleName")); - VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).identifier, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).name, @"exampleName")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentNavigatorTarget_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current navigator target: Error: %@", err); - } else { - NSLog(@"Read attribute current navigator target: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentTarget", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestNavigateTargetRequestCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; - params.target = - [NSNumber numberWithUnsignedChar:1U]; - params.data = @"1"; - [cluster navigateTargetWithParams:params completion: - ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Navigate Target Request Command: Error: %@", err); - } else { - NSLog(@"Navigate Target Request Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_AudioOutputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_AudioOutputCluster() - : TestCommandBridge("TV_AudioOutputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_AudioOutputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_AudioOutputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_AudioOutputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Audio Output list\n"); - err = TestReadAttributeAudioOutputList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current audio output\n"); - err = TestReadAttributeCurrentAudioOutput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Select Output Command\n"); - err = TestSelectOutputCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Rename Output Command\n"); - err = TestRenameOutputCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute Audio Output list\n"); - err = TestReadAttributeAudioOutputList_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeAudioOutputList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Audio Output list: Error: %@", err); - } else { - NSLog(@"Read attribute Audio Output list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentAudioOutput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current audio output: Error: %@", err); - } else { - NSLog(@"Read attribute current audio output: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentOutput", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSelectOutputCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - [cluster selectOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Select Output Command: Error: %@", err); - } else { - NSLog(@"Select Output Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRenameOutputCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - params.name = @"HDMI Test"; - [cluster renameOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Rename Output Command: Error: %@", err); - } else { - NSLog(@"Rename Output Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeAudioOutputList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Audio Output list: Error: %@", err); - } else { - NSLog(@"Read attribute Audio Output list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI Test")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ApplicationLauncherCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ApplicationLauncherCluster() - : TestCommandBridge("TV_ApplicationLauncherCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ApplicationLauncherCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationLauncherCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationLauncherCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Application Launcher list\n"); - err = TestReadAttributeApplicationLauncherList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute application launcher app\n"); - err = TestReadAttributeApplicationLauncherApp_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Launch App Command\n"); - err = TestLaunchAppCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Stop App Command\n"); - err = TestStopAppCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Hide App Command\n"); - err = TestHideAppCommand_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeApplicationLauncherList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Application Launcher list: Error: %@", err); - } else { - NSLog(@"Read attribute Application Launcher list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CatalogList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 123U)); - VerifyOrReturn(CheckValue("", actualValue[1], 456U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationLauncherApp_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application launcher app: Error: %@", err); - } else { - NSLog(@"Read attribute application launcher app: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentApp", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchAppCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - params.data = - [[NSData alloc] initWithBytes:"data" length:4]; - [cluster launchAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch App Command: Error: %@", err); - } else { - NSLog(@"Launch App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopAppCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterStopAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - [cluster stopAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop App Command: Error: %@", err); - } else { - NSLog(@"Stop App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestHideAppCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterHideAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - [cluster hideAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Hide App Command: Error: %@", err); - } else { - NSLog(@"Hide App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_KeypadInputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_KeypadInputCluster() - : TestCommandBridge("TV_KeypadInputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_KeypadInputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_KeypadInputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_KeypadInputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Key Command\n"); - err = TestSendKeyCommand_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendKeyCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:3U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Key Command: Error: %@", err); - } else { - NSLog(@"Send Key Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_AccountLoginCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_AccountLoginCluster() - : TestCommandBridge("TV_AccountLoginCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_AccountLoginCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_AccountLoginCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_AccountLoginCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get Setup PIN Command\n"); - err = TestGetSetupPinCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Login Command\n"); - err = TestLoginCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Logout Command\n"); - err = TestLogoutCommand_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestGetSetupPinCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; - params.tempAccountIdentifier = @"asdf"; - [cluster getSetupPINWithParams:params completion: - ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Setup PIN Command: Error: %@", err); - } else { - NSLog(@"Get Setup PIN Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.setupPIN; - VerifyOrReturn(CheckValueAsString("SetupPIN", actualValue, @"tempPin123")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLoginCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; - params.tempAccountIdentifier = @"asdf"; - params.setupPIN = @"tempPin123"; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster loginWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Login Command: Error: %@", err); - } else { - NSLog(@"Login Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLogoutCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster logoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Logout Command: Error: %@", err); - } else { - NSLog(@"Logout Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_WakeOnLanCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_WakeOnLanCluster() - : TestCommandBridge("TV_WakeOnLanCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_WakeOnLanCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_WakeOnLanCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_WakeOnLanCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read mac address\n"); - err = TestReadMacAddress_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadMacAddress_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read mac address: Error: %@", err); - } else { - NSLog(@"Read mac address: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 3)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ApplicationBasicCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ApplicationBasicCluster() - : TestCommandBridge("TV_ApplicationBasicCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ApplicationBasicCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationBasicCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationBasicCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute vendor name\n"); - err = TestReadAttributeVendorName_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute vendor id\n"); - err = TestReadAttributeVendorId_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute application name\n"); - err = TestReadAttributeApplicationName_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute product id\n"); - err = TestReadAttributeProductId_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute application status\n"); - err = TestReadAttributeApplicationStatus_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute application status\n"); - err = TestReadAttributeApplicationStatus_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute application version\n"); - err = TestReadAttributeApplicationVersion_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute application allowed vendor list\n"); - err = TestReadAttributeApplicationAllowedVendorList_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeVendorName_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor name: Error: %@", err); - } else { - NSLog(@"Read attribute vendor name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("VendorName", actualValue, @"exampleVendorName1")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorId_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor id: Error: %@", err); - } else { - NSLog(@"Read attribute vendor id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("VendorID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationName_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application name: Error: %@", err); - } else { - NSLog(@"Read attribute application name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("ApplicationName", actualValue, @"exampleName1")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeProductId_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute product id: Error: %@", err); - } else { - NSLog(@"Read attribute product id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ProductID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationStatus_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application status: Error: %@", err); - } else { - NSLog(@"Read attribute application status: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationStatus_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application status: Error: %@", err); - } else { - NSLog(@"Read attribute application status: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CatalogVendorID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).catalogVendorID, 123U)); - VerifyOrReturn(CheckValueAsString("ApplicationID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).applicationID, @"applicationId")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationVersion_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application version: Error: %@", err); - } else { - NSLog(@"Read attribute application version: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("ApplicationVersion", actualValue, @"exampleVersion")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationAllowedVendorList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application allowed vendor list: Error: %@", err); - } else { - NSLog(@"Read attribute application allowed vendor list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AllowedVendorList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 456U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_MediaPlaybackCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_MediaPlaybackCluster() - : TestCommandBridge("TV_MediaPlaybackCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_MediaPlaybackCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_MediaPlaybackCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_MediaPlaybackCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute playback state\n"); - err = TestReadAttributePlaybackState_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute start time\n"); - err = TestReadAttributeStartTime_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute duration\n"); - err = TestReadAttributeDuration_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute position\n"); - err = TestReadAttributePosition_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute playback speed\n"); - err = TestReadAttributePlaybackSpeed_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute seek range end\n"); - err = TestReadAttributeSeekRangeEnd_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute seek range start\n"); - err = TestReadAttributeSeekRangeStart_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Media Playback Play Command\n"); - err = TestMediaPlaybackPlayCommand_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Media Playback Pause Command\n"); - err = TestMediaPlaybackPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Media Playback Stop Command\n"); - err = TestMediaPlaybackStopCommand_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Media Playback Start Over Command\n"); - err = TestMediaPlaybackStartOverCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Media Playback Previous Command\n"); - err = TestMediaPlaybackPreviousCommand_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Media Playback Next Command\n"); - err = TestMediaPlaybackNextCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Media Playback Rewind Command\n"); - err = TestMediaPlaybackRewindCommand_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Media Playback Fast Forward Command\n"); - err = TestMediaPlaybackFastForwardCommand_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Media Playback Skip Forward Command\n"); - err = TestMediaPlaybackSkipForwardCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute position after skip forward\n"); - err = TestReadAttributePositionAfterSkipForward_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Media Playback Skip Backward Command\n"); - err = TestMediaPlaybackSkipBackwardCommand_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute position after skip backward\n"); - err = TestReadAttributePositionAfterSkipBackward_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Media Playback Seek Command\n"); - err = TestMediaPlaybackSeekCommand_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute position after seek\n"); - err = TestReadAttributePositionAfterSeek_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributePlaybackState_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute playback state: Error: %@", err); - } else { - NSLog(@"Read attribute playback state: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeStartTime_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute start time: Error: %@", err); - } else { - NSLog(@"Read attribute start time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartTime", actualValue)); - VerifyOrReturn(CheckValue("StartTime", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDuration_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute duration: Error: %@", err); - } else { - NSLog(@"Read attribute duration: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("Duration", actualValue)); - VerifyOrReturn(CheckValue("Duration", actualValue, 80000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePosition_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position: Error: %@", err); - } else { - NSLog(@"Read attribute position: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePlaybackSpeed_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute playback speed: Error: %@", err); - } else { - NSLog(@"Read attribute playback speed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSeekRangeEnd_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute seek range end: Error: %@", err); - } else { - NSLog(@"Read attribute seek range end: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SeekRangeEnd", actualValue)); - VerifyOrReturn(CheckValue("SeekRangeEnd", actualValue, 80000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSeekRangeStart_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute seek range start: Error: %@", err); - } else { - NSLog(@"Read attribute seek range start: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SeekRangeStart", actualValue)); - VerifyOrReturn(CheckValue("SeekRangeStart", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPlayCommand_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Play Command: Error: %@", err); - } else { - NSLog(@"Media Playback Play Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Pause Command: Error: %@", err); - } else { - NSLog(@"Media Playback Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackStopCommand_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Stop Command: Error: %@", err); - } else { - NSLog(@"Media Playback Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackStartOverCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startOverWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Start Over Command: Error: %@", err); - } else { - NSLog(@"Media Playback Start Over Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPreviousCommand_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster previousWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Previous Command: Error: %@", err); - } else { - NSLog(@"Media Playback Previous Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackNextCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster nextWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Next Command: Error: %@", err); - } else { - NSLog(@"Media Playback Next Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackRewindCommand_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Rewind Command: Error: %@", err); - } else { - NSLog(@"Media Playback Rewind Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackFastForwardCommand_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Fast Forward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Fast Forward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSkipForwardCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:500ULL]; - [cluster skipForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Skip Forward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Skip Forward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSkipForward_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after skip forward: Error: %@", err); - } else { - NSLog(@"Read attribute position after skip forward: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 500ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSkipBackwardCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:100ULL]; - [cluster skipBackwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Skip Backward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Skip Backward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSkipBackward_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after skip backward: Error: %@", err); - } else { - NSLog(@"Read attribute position after skip backward: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 400ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSeekCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = - [NSNumber numberWithUnsignedLongLong:1000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Seek Command: Error: %@", err); - } else { - NSLog(@"Media Playback Seek Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSeek_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after seek: Error: %@", err); - } else { - NSLog(@"Read attribute position after seek: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 1000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ChannelCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ChannelCluster() - : TestCommandBridge("TV_ChannelCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ChannelCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ChannelCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ChannelCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Channel list\n"); - err = TestReadAttributeChannelList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute channel lineup\n"); - err = TestReadAttributeChannelLineup_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute current channel\n"); - err = TestReadAttributeCurrentChannel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Change Channel Command\n"); - err = TestChangeChannelCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Change Channel By Number Command\n"); - err = TestChangeChannelByNumberCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Skip Channel Command\n"); - err = TestSkipChannelCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that Skip Channel Command set correct current channel\n"); - err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Skip Channel Command\n"); - err = TestSkipChannelCommand_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that Skip Channel Command set correct current channel\n"); - err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Test 1.1 - Start from Channel 3\n"); - err = TestTest11StartFromChannel3_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Test 1.2 - Skip Up By 1\n"); - err = TestTest12SkipUpBy1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Test 2.1 - Start from Channel 3\n"); - err = TestTest21StartFromChannel3_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Test 2.2 - Skip Up By 2\n"); - err = TestTest22SkipUpBy2_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Test 3.1 - Start from Channel 3\n"); - err = TestTest31StartFromChannel3_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Test 3.2 - Skip Up By 3\n"); - err = TestTest32SkipUpBy3_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Test 4.1 - Start from Channel 3\n"); - err = TestTest41StartFromChannel3_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Test 4.2 - Skip Up By 4\n"); - err = TestTest42SkipUpBy4_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Test 5.2 - Skip Up By 5\n"); - err = TestTest52SkipUpBy5_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Test 6.1 - Start from Channel 3\n"); - err = TestTest61StartFromChannel3_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Test 6.2 - Skip Up By 6\n"); - err = TestTest62SkipUpBy6_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Test 7.1 - Start from Channel 3\n"); - err = TestTest71StartFromChannel3_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Test 7.2 - Skip Up By 7\n"); - err = TestTest72SkipUpBy7_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Test 8.1 - Start from Channel 3\n"); - err = TestTest81StartFromChannel3_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Test 8.2 - Skip Up By 8\n"); - err = TestTest82SkipUpBy8_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Test 1.2 - Skip Down By 1\n"); - err = TestTest12SkipDownBy1_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Test 2.1 - Start from Channel 3\n"); - err = TestTest21StartFromChannel3_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Test 2.2 - Skip Down By 2\n"); - err = TestTest22SkipDownBy2_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Test 3.1 - Start from Channel 3\n"); - err = TestTest31StartFromChannel3_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Test 3.2 - Skip Down By 3\n"); - err = TestTest32SkipDownBy3_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Test 4.1 - Start from Channel 3\n"); - err = TestTest41StartFromChannel3_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Test 4.2 - Skip Down By 4\n"); - err = TestTest42SkipDownBy4_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Test 5.2 - Skip Down By 5\n"); - err = TestTest52SkipDownBy5_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Test 6.1 - Start from Channel 3\n"); - err = TestTest61StartFromChannel3_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Test 6.2 - Skip Down By 6\n"); - err = TestTest62SkipDownBy6_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Test 7.1 - Start from Channel 3\n"); - err = TestTest71StartFromChannel3_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Test 7.2 - Skip Down By 7\n"); - err = TestTest72SkipDownBy7_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Test 8.1 - Start from Channel 3\n"); - err = TestTest81StartFromChannel3_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Test 8.2 - Skip Down By 8\n"); - err = TestTest82SkipDownBy8_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Test 1.2 - Skip Up By 32,767\n"); - err = TestTest12SkipUpBy32767_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Test 1.1 - Start from Channel 3\n"); - err = TestTest11StartFromChannel3_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Test 1.2 - Skip Down By 32,768\n"); - err = TestTest12SkipDownBy32768_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 60; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeChannelList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Channel list: Error: %@", err); - } else { - NSLog(@"Read attribute Channel list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ChannelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).affiliateCallSign, @"KAAL")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).affiliateCallSign, @"KCTS")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).affiliateCallSign, @"KCTS")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeChannelLineup_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute channel lineup: Error: %@", err); - } else { - NSLog(@"Read attribute channel lineup: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("Lineup", actualValue)); - VerifyOrReturn(CheckValueAsString("OperatorName", ((MTRChannelClusterLineupInfoStruct *) actualValue).operatorName, @"Comcast")); - VerifyOrReturn(CheckValueAsString("LineupName", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupName, @"Comcast King County")); - VerifyOrReturn(CheckValueAsString("PostalCode", ((MTRChannelClusterLineupInfoStruct *) actualValue).postalCode, @"98052")); - VerifyOrReturn(CheckValue("LineupInfoType", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupInfoType, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentChannel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current channel: Error: %@", err); - } else { - NSLog(@"Read attribute current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeChannelCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelParams alloc] init]; - params.match = @"PBS"; - [cluster changeChannelWithParams:params completion: - ^(MTRChannelClusterChangeChannelResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change Channel Command: Error: %@", err); - } else { - NSLog(@"Change Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeChannelByNumberCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:6U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:0U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change Channel By Number Command: Error: %@", err); - } else { - NSLog(@"Change Channel By Number Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSkipChannelCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Skip Channel Command: Error: %@", err); - } else { - NSLog(@"Skip Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSkipChannelCommand_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:123]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Skip Channel Command: Error: %@", err); - } else { - NSLog(@"Skip Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest11StartFromChannel3_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 1.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipUpBy1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Up By 1: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Up By 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest21StartFromChannel3_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 2.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest22SkipUpBy2_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.2 - Skip Up By 2: Error: %@", err); - } else { - NSLog(@"Test 2.2 - Skip Up By 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest31StartFromChannel3_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 3.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest32SkipUpBy3_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:3]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.2 - Skip Up By 3: Error: %@", err); - } else { - NSLog(@"Test 3.2 - Skip Up By 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest41StartFromChannel3_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 4.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest42SkipUpBy4_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:4]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.2 - Skip Up By 4: Error: %@", err); - } else { - NSLog(@"Test 4.2 - Skip Up By 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest52SkipUpBy5_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:5]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.2 - Skip Up By 5: Error: %@", err); - } else { - NSLog(@"Test 5.2 - Skip Up By 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest61StartFromChannel3_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 6.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest62SkipUpBy6_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:6]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.2 - Skip Up By 6: Error: %@", err); - } else { - NSLog(@"Test 6.2 - Skip Up By 6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest71StartFromChannel3_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 7.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest72SkipUpBy7_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:7]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.2 - Skip Up By 7: Error: %@", err); - } else { - NSLog(@"Test 7.2 - Skip Up By 7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest81StartFromChannel3_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 8.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest82SkipUpBy8_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:8]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.2 - Skip Up By 8: Error: %@", err); - } else { - NSLog(@"Test 8.2 - Skip Up By 8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipDownBy1_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Down By 1: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Down By 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest21StartFromChannel3_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 2.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest22SkipDownBy2_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.2 - Skip Down By 2: Error: %@", err); - } else { - NSLog(@"Test 2.2 - Skip Down By 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest31StartFromChannel3_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 3.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest32SkipDownBy3_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-3]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.2 - Skip Down By 3: Error: %@", err); - } else { - NSLog(@"Test 3.2 - Skip Down By 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest41StartFromChannel3_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 4.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest42SkipDownBy4_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-4]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.2 - Skip Down By 4: Error: %@", err); - } else { - NSLog(@"Test 4.2 - Skip Down By 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest52SkipDownBy5_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-5]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.2 - Skip Down By 5: Error: %@", err); - } else { - NSLog(@"Test 5.2 - Skip Down By 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest61StartFromChannel3_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 6.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest62SkipDownBy6_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-6]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.2 - Skip Down By 6: Error: %@", err); - } else { - NSLog(@"Test 6.2 - Skip Down By 6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest71StartFromChannel3_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 7.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest72SkipDownBy7_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-7]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.2 - Skip Down By 7: Error: %@", err); - } else { - NSLog(@"Test 7.2 - Skip Down By 7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest81StartFromChannel3_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 8.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest82SkipDownBy8_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-8]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.2 - Skip Down By 8: Error: %@", err); - } else { - NSLog(@"Test 8.2 - Skip Down By 8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipUpBy32767_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:32767]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Up By 32,767: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Up By 32,767: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest11StartFromChannel3_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 1.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipDownBy32768_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-32768]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Down By 32,768: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Down By 32,768: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_LowPowerCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_LowPowerCluster() - : TestCommandBridge("TV_LowPowerCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_LowPowerCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_LowPowerCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_LowPowerCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Sleep Input Status Command\n"); - err = TestSleepInputStatusCommand_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSleepInputStatusCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sleep Input Status Command: Error: %@", err); - } else { - NSLog(@"Sleep Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ContentLauncherCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ContentLauncherCluster() - : TestCommandBridge("TV_ContentLauncherCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ContentLauncherCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ContentLauncherCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ContentLauncherCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute accept header list\n"); - err = TestReadAttributeAcceptHeaderList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute supported streaming protocols\n"); - err = TestReadAttributeSupportedStreamingProtocols_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Launch Content Command\n"); - err = TestLaunchContentCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Launch URL Command\n"); - err = TestLaunchUrlCommand_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeAcceptHeaderList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute accept header list: Error: %@", err); - } else { - NSLog(@"Read attribute accept header list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptHeader", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], @"example")); - VerifyOrReturn(CheckValueAsString("", actualValue[1], @"example")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSupportedStreamingProtocols_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute supported streaming protocols: Error: %@", err); - } else { - NSLog(@"Read attribute supported streaming protocols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedStreamingProtocols", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchContentCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.data = @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:true]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch Content Command: Error: %@", err); - } else { - NSLog(@"Launch Content Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchUrlCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = @"exampleUrl"; - params.displayString = @"exampleDisplayString"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = @"exampleName"; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch URL Command: Error: %@", err); - } else { - NSLog(@"Launch URL Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_MediaInputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_MediaInputCluster() - : TestCommandBridge("TV_MediaInputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_MediaInputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_MediaInputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_MediaInputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute media input list\n"); - err = TestReadAttributeMediaInputList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current media input\n"); - err = TestReadCurrentMediaInput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Select Input Command\n"); - err = TestSelectInputCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Hide Input Status Command\n"); - err = TestHideInputStatusCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Show Input Status Command\n"); - err = TestShowInputStatusCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Rename Input Command\n"); - err = TestRenameInputCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute media input list\n"); - err = TestReadAttributeMediaInputList_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeMediaInputList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute media input list: Error: %@", err); - } else { - NSLog(@"Read attribute media input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentMediaInput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current media input: Error: %@", err); - } else { - NSLog(@"Read current media input: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentInput", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSelectInputCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - [cluster selectInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Select Input Command: Error: %@", err); - } else { - NSLog(@"Select Input Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestHideInputStatusCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster hideInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Hide Input Status Command: Error: %@", err); - } else { - NSLog(@"Hide Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestShowInputStatusCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster showInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Show Input Status Command: Error: %@", err); - } else { - NSLog(@"Show Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRenameInputCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - params.name = @"HDMI Test"; - [cluster renameInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Rename Input Command: Error: %@", err); - } else { - NSLog(@"Rename Input Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeMediaInputList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute media input list: Error: %@", err); - } else { - NSLog(@"Read attribute media input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI Test")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCASERecovery : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCASERecovery() - : TestCommandBridge("TestCASERecovery") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCASERecovery() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCASERecovery\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCASERecovery\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read an attribute\n"); - err = TestReadAnAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Reboot the server\n"); - err = TestRebootTheServer_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Re-get our session, but without expiring sesssions\n"); - err = TestReGetOurSessionButWithoutExpiringSesssions_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read an attribute again\n"); - err = TestReadAnAttributeAgain_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Re-get our session, but without expiring sesssions\n"); - err = TestReGetOurSessionButWithoutExpiringSesssions_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read an attribute a third time\n"); - err = TestReadAnAttributeAThirdTime_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute: Error: %@", err); - } else { - NSLog(@"Read an attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTheServer_2() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.expireExistingSession.Emplace(); - value.expireExistingSession.Value() = false; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttributeAgain_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute again: Error: %@", err); - } else { - NSLog(@"Read an attribute again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.expireExistingSession.Emplace(); - value.expireExistingSession.Value() = false; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttributeAThirdTime_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute a third time: Error: %@", err); - } else { - NSLog(@"Read an attribute a third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCluster() - : TestCommandBridge("TestCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Command\n"); - err = TestSendTestCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Not Handled Command\n"); - err = TestSendTestNotHandledCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Specific Command\n"); - err = TestSendTestSpecificCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Send failing Test Add Arguments Command\n"); - err = TestSendFailingTestAddArgumentsCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Default Value\n"); - err = TestReadAttributeBooleanDefaultValue_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN True\n"); - err = TestWriteAttributeBooleanTrue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN True\n"); - err = TestReadAttributeBooleanTrue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write attribute BOOLEAN False\n"); - err = TestWriteAttributeBooleanFalse_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BOOLEAN False\n"); - err = TestReadAttributeBooleanFalse_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Max Value\n"); - err = TestWriteAttributeBitmap8MaxValue_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Max Value\n"); - err = TestReadAttributeBitmap8MaxValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute BITMAP8 Min Value\n"); - err = TestWriteAttributeBitmap8MinValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute BITMAP8 Min Value\n"); - err = TestReadAttributeBitmap8MinValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Max Value\n"); - err = TestWriteAttributeBitmap16MaxValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Max Value\n"); - err = TestReadAttributeBitmap16MaxValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute BITMAP16 Min Value\n"); - err = TestWriteAttributeBitmap16MinValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute BITMAP16 Min Value\n"); - err = TestReadAttributeBitmap16MinValue_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Max Value\n"); - err = TestWriteAttributeBitmap32MaxValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Max Value\n"); - err = TestReadAttributeBitmap32MaxValue_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute BITMAP32 Min Value\n"); - err = TestWriteAttributeBitmap32MinValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute BITMAP32 Min Value\n"); - err = TestReadAttributeBitmap32MinValue_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Max Value\n"); - err = TestWriteAttributeBitmap64MaxValue_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Max Value\n"); - err = TestReadAttributeBitmap64MaxValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Write attribute BITMAP64 Min Value\n"); - err = TestWriteAttributeBitmap64MinValue_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Read attribute BITMAP64 Min Value\n"); - err = TestReadAttributeBitmap64MinValue_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Max Value\n"); - err = TestWriteAttributeInt8uMaxValue_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Max Value\n"); - err = TestReadAttributeInt8uMaxValue_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute INT8U Min Value\n"); - err = TestWriteAttributeInt8uMinValue_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute INT8U Min Value\n"); - err = TestReadAttributeInt8uMinValue_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Max Value\n"); - err = TestWriteAttributeInt16uMaxValue_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Max Value\n"); - err = TestReadAttributeInt16uMaxValue_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Write attribute INT16U Min Value\n"); - err = TestWriteAttributeInt16uMinValue_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Read attribute INT16U Min Value\n"); - err = TestReadAttributeInt16uMinValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Max Value\n"); - err = TestWriteAttributeInt32uMaxValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Max Value\n"); - err = TestReadAttributeInt32uMaxValue_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute INT32U Min Value\n"); - err = TestWriteAttributeInt32uMinValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Read attribute INT32U Min Value\n"); - err = TestReadAttributeInt32uMinValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Max Value\n"); - err = TestWriteAttributeInt64uMaxValue_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Max Value\n"); - err = TestReadAttributeInt64uMaxValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Write attribute INT64U Min Value\n"); - err = TestWriteAttributeInt64uMinValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Read attribute INT64U Min Value\n"); - err = TestReadAttributeInt64uMinValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Max Value\n"); - err = TestWriteAttributeInt8sMaxValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Max Value\n"); - err = TestReadAttributeInt8sMaxValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute INT8S Min Value\n"); - err = TestWriteAttributeInt8sMinValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute INT8S Min Value\n"); - err = TestReadAttributeInt8sMinValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute INT8S Default Value\n"); - err = TestWriteAttributeInt8sDefaultValue_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Write attribute INT16S Max Value\n"); - err = TestWriteAttributeInt16sMaxValue_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Read attribute INT16S Max Value\n"); - err = TestReadAttributeInt16sMaxValue_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Write attribute INT16S Min Value\n"); - err = TestWriteAttributeInt16sMinValue_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Read attribute INT16S Min Value\n"); - err = TestReadAttributeInt16sMinValue_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Write attribute INT16S Default Value\n"); - err = TestWriteAttributeInt16sDefaultValue_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Write attribute INT32S Max Value\n"); - err = TestWriteAttributeInt32sMaxValue_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Read attribute INT32S Max Value\n"); - err = TestReadAttributeInt32sMaxValue_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Write attribute INT32S Min Value\n"); - err = TestWriteAttributeInt32sMinValue_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute INT32S Min Value\n"); - err = TestReadAttributeInt32sMinValue_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute INT32S Default Value\n"); - err = TestWriteAttributeInt32sDefaultValue_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Write attribute INT64S Max Value\n"); - err = TestWriteAttributeInt64sMaxValue_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute INT64S Max Value\n"); - err = TestReadAttributeInt64sMaxValue_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute INT64S Min Value\n"); - err = TestWriteAttributeInt64sMinValue_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute INT64S Min Value\n"); - err = TestReadAttributeInt64sMinValue_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute INT64S Default Value\n"); - err = TestWriteAttributeInt64sDefaultValue_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute SINGLE Default Value\n"); - err = TestReadAttributeSingleDefaultValue_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute SINGLE medium Value\n"); - err = TestWriteAttributeSingleMediumValue_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute SINGLE medium Value\n"); - err = TestReadAttributeSingleMediumValue_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute SINGLE large Value\n"); - err = TestWriteAttributeSingleLargeValue_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute SINGLE large Value\n"); - err = TestReadAttributeSingleLargeValue_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Write attribute SINGLE small Value\n"); - err = TestWriteAttributeSingleSmallValue_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Read attribute SINGLE small Value\n"); - err = TestReadAttributeSingleSmallValue_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Write attribute SINGLE Default Value\n"); - err = TestWriteAttributeSingleDefaultValue_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Read attribute SINGLE Default Value\n"); - err = TestReadAttributeSingleDefaultValue_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute DOUBLE Default Value\n"); - err = TestReadAttributeDoubleDefaultValue_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Write attribute DOUBLE medium Value\n"); - err = TestWriteAttributeDoubleMediumValue_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Read attribute DOUBLE medium Value\n"); - err = TestReadAttributeDoubleMediumValue_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Write attribute DOUBLE large Value\n"); - err = TestWriteAttributeDoubleLargeValue_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Read attribute DOUBLE large Value\n"); - err = TestReadAttributeDoubleLargeValue_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Write attribute DOUBLE small Value\n"); - err = TestWriteAttributeDoubleSmallValue_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute DOUBLE small Value\n"); - err = TestReadAttributeDoubleSmallValue_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Write attribute DOUBLE Default Value\n"); - err = TestWriteAttributeDoubleDefaultValue_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Read attribute DOUBLE Default Value\n"); - err = TestReadAttributeDoubleDefaultValue_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Write attribute ENUM8 Max Value\n"); - err = TestWriteAttributeEnum8MaxValue_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Read attribute ENUM8 Max Value\n"); - err = TestReadAttributeEnum8MaxValue_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Write attribute ENUM8 Min Value\n"); - err = TestWriteAttributeEnum8MinValue_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Read attribute ENUM8 Min Value\n"); - err = TestReadAttributeEnum8MinValue_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Write attribute ENUM16 Max Value\n"); - err = TestWriteAttributeEnum16MaxValue_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Read attribute ENUM16 Max Value\n"); - err = TestReadAttributeEnum16MaxValue_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Write attribute ENUM16 Min Value\n"); - err = TestWriteAttributeEnum16MinValue_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute ENUM16 Min Value\n"); - err = TestReadAttributeEnum16MinValue_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Read attribute OCTET_STRING Default Value\n"); - err = TestReadAttributeOctetStringDefaultValue_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Write attribute OCTET_STRING with embedded null\n"); - err = TestWriteAttributeOctetStringWithEmbeddedNull_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Read attribute OCTET_STRING with embedded null\n"); - err = TestReadAttributeOctetStringWithEmbeddedNull_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Write attribute OCTET_STRING with hex: format\n"); - err = TestWriteAttributeOctetStringWithHexFormat_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Read attribute OCTET_STRING with hex: format\n"); - err = TestReadAttributeOctetStringWithHexFormat_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Write attribute OCTET_STRING with weird chars\n"); - err = TestWriteAttributeOctetStringWithWeirdChars_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute OCTET_STRING with weird chars\n"); - err = TestReadAttributeOctetStringWithWeirdChars_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Read attribute OCTET_STRING\n"); - err = TestReadAttributeOctetString_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Read attribute OCTET_STRING\n"); - err = TestReadAttributeOctetString_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Read attribute LONG_OCTET_STRING Default Value\n"); - err = TestReadAttributeLongOctetStringDefaultValue_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Write attribute LONG_OCTET_STRING\n"); - err = TestWriteAttributeLongOctetString_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Read attribute LONG_OCTET_STRING\n"); - err = TestReadAttributeLongOctetString_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Write attribute LONG_OCTET_STRING\n"); - err = TestWriteAttributeLongOctetString_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Read attribute CHAR_STRING Default Value\n"); - err = TestReadAttributeCharStringDefaultValue_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Write attribute CHAR_STRING\n"); - err = TestWriteAttributeCharString_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Read attribute CHAR_STRING\n"); - err = TestReadAttributeCharString_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Write attribute CHAR_STRING - Value too long\n"); - err = TestWriteAttributeCharStringValueTooLong_126(); - break; - case 127: - ChipLogProgress(chipTool, " ***** Test Step 127 : Read attribute CHAR_STRING\n"); - err = TestReadAttributeCharString_127(); - break; - case 128: - ChipLogProgress(chipTool, " ***** Test Step 128 : Write attribute CHAR_STRING - Empty\n"); - err = TestWriteAttributeCharStringEmpty_128(); - break; - case 129: - ChipLogProgress(chipTool, " ***** Test Step 129 : Read attribute LONG_CHAR_STRING Default Value\n"); - err = TestReadAttributeLongCharStringDefaultValue_129(); - break; - case 130: - ChipLogProgress(chipTool, " ***** Test Step 130 : Write attribute LONG_CHAR_STRING\n"); - err = TestWriteAttributeLongCharString_130(); - break; - case 131: - ChipLogProgress(chipTool, " ***** Test Step 131 : Read attribute LONG_CHAR_STRING\n"); - err = TestReadAttributeLongCharString_131(); - break; - case 132: - ChipLogProgress(chipTool, " ***** Test Step 132 : Write attribute LONG_CHAR_STRING\n"); - err = TestWriteAttributeLongCharString_132(); - break; - case 133: - ChipLogProgress(chipTool, " ***** Test Step 133 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); - err = TestReadAttributeListLongOctetStringForChunkedRead_133(); - break; - case 134: - ChipLogProgress(chipTool, " ***** Test Step 134 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); - err = TestWriteAttributeListLongOctetStringForChunkedWrite_134(); - break; - case 135: - ChipLogProgress(chipTool, " ***** Test Step 135 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); - err = TestReadAttributeListLongOctetStringForChunkedRead_135(); - break; - case 136: - ChipLogProgress(chipTool, " ***** Test Step 136 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); - err = TestWriteAttributeListLongOctetStringForChunkedWrite_136(); - break; - case 137: - ChipLogProgress(chipTool, " ***** Test Step 137 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_137(); - break; - case 138: - ChipLogProgress(chipTool, " ***** Test Step 138 : Write attribute EPOCH_US Max Value\n"); - err = TestWriteAttributeEpochUsMaxValue_138(); - break; - case 139: - ChipLogProgress(chipTool, " ***** Test Step 139 : Read attribute EPOCH_US Max Value\n"); - err = TestReadAttributeEpochUsMaxValue_139(); - break; - case 140: - ChipLogProgress(chipTool, " ***** Test Step 140 : Write attribute EPOCH_US Min Value\n"); - err = TestWriteAttributeEpochUsMinValue_140(); - break; - case 141: - ChipLogProgress(chipTool, " ***** Test Step 141 : Read attribute EPOCH_US Min Value\n"); - err = TestReadAttributeEpochUsMinValue_141(); - break; - case 142: - ChipLogProgress(chipTool, " ***** Test Step 142 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_142(); - break; - case 143: - ChipLogProgress(chipTool, " ***** Test Step 143 : Write attribute EPOCH_S Max Value\n"); - err = TestWriteAttributeEpochSMaxValue_143(); - break; - case 144: - ChipLogProgress(chipTool, " ***** Test Step 144 : Read attribute EPOCH_S Max Value\n"); - err = TestReadAttributeEpochSMaxValue_144(); - break; - case 145: - ChipLogProgress(chipTool, " ***** Test Step 145 : Write attribute EPOCH_S Min Value\n"); - err = TestWriteAttributeEpochSMinValue_145(); - break; - case 146: - ChipLogProgress(chipTool, " ***** Test Step 146 : Read attribute EPOCH_S Min Value\n"); - err = TestReadAttributeEpochSMinValue_146(); - break; - case 147: - ChipLogProgress(chipTool, " ***** Test Step 147 : Read attribute UNSUPPORTED\n"); - err = TestReadAttributeUnsupported_147(); - break; - case 148: - ChipLogProgress(chipTool, " ***** Test Step 148 : Writeattribute UNSUPPORTED\n"); - err = TestWriteattributeUnsupported_148(); - break; - case 149: - ChipLogProgress(chipTool, " ***** Test Step 149 : Send Test Command to unsupported endpoint\n"); - err = TestSendTestCommandToUnsupportedEndpoint_149(); - break; - case 150: - ChipLogProgress(chipTool, " ***** Test Step 150 : Send Test Command to unsupported cluster\n"); - err = TestSendTestCommandToUnsupportedCluster_150(); - break; - case 151: - ChipLogProgress(chipTool, " ***** Test Step 151 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_151(); - break; - case 152: - ChipLogProgress(chipTool, " ***** Test Step 152 : Write attribute vendor_id\n"); - err = TestWriteAttributeVendorId_152(); - break; - case 153: - ChipLogProgress(chipTool, " ***** Test Step 153 : Read attribute vendor_id\n"); - err = TestReadAttributeVendorId_153(); - break; - case 154: - ChipLogProgress(chipTool, " ***** Test Step 154 : Restore attribute vendor_id\n"); - err = TestRestoreAttributeVendorId_154(); - break; - case 155: - ChipLogProgress(chipTool, " ***** Test Step 155 : Send a command with a vendor_id and enum\n"); - err = TestSendACommandWithAVendorIdAndEnum_155(); - break; - case 156: - ChipLogProgress(chipTool, " ***** Test Step 156 : Send a command with a vendor_id and invalid enum\n"); - err = TestSendACommandWithAVendorIdAndInvalidEnum_156(); - break; - case 157: - ChipLogProgress(chipTool, " ***** Test Step 157 : Send Test Command With Struct Argument and arg1.b is true\n"); - err = TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157(); - break; - case 158: - ChipLogProgress(chipTool, " ***** Test Step 158 : Send Test Command With Struct Argument and arg1.b is false\n"); - err = TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158(); - break; - case 159: - ChipLogProgress(chipTool, " ***** Test Step 159 : Send Test Command With Nested Struct Argument and arg1.c.b is true\n"); - err = TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159(); - break; - case 160: - ChipLogProgress(chipTool, " ***** Test Step 160 : Send Test Command With Nested Struct Argument arg1.c.b is false\n"); - err = TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160(); - break; - case 161: - ChipLogProgress(chipTool, " ***** Test Step 161 : Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161(); - break; - case 162: - ChipLogProgress(chipTool, " ***** Test Step 162 : Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162(); - break; - case 163: - ChipLogProgress(chipTool, " ***** Test Step 163 : Send Test Command With Struct Argument and see what we get back\n"); - err = TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163(); - break; - case 164: - ChipLogProgress(chipTool, " ***** Test Step 164 : Send Test Command With List of INT8U and none of them is set to 0\n"); - err = TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_164(); - break; - case 165: - ChipLogProgress(chipTool, " ***** Test Step 165 : Send Test Command With List of INT8U and one of them is set to 0\n"); - err = TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_165(); - break; - case 166: - ChipLogProgress(chipTool, " ***** Test Step 166 : Send Test Command With List of INT8U and get it reversed\n"); - err = TestSendTestCommandWithListOfInt8uAndGetItReversed_166(); - break; - case 167: - ChipLogProgress(chipTool, " ***** Test Step 167 : Send Test Command With empty List of INT8U and get an empty list back\n"); - err = TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_167(); - break; - case 168: - ChipLogProgress(chipTool, " ***** Test Step 168 : Send Test Command With List of Struct Argument and arg1.b of first item is true\n"); - err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_168(); - break; - case 169: - ChipLogProgress(chipTool, " ***** Test Step 169 : Send Test Command With List of Struct Argument and arg1.b of first item is false\n"); - err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_169(); - break; - case 170: - ChipLogProgress(chipTool, " ***** Test Step 170 : Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true\n"); - err = TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_170(); - break; - case 171: - ChipLogProgress(chipTool, " ***** Test Step 171 : Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_171(); - break; - case 172: - ChipLogProgress(chipTool, " ***** Test Step 172 : Write attribute LIST With List of INT8U and none of them is set to 0\n"); - err = TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_172(); - break; - case 173: - ChipLogProgress(chipTool, " ***** Test Step 173 : Read attribute LIST With List of INT8U\n"); - err = TestReadAttributeListWithListOfInt8u_173(); - break; - case 174: - ChipLogProgress(chipTool, " ***** Test Step 174 : Write attribute LIST With List of OCTET_STRING\n"); - err = TestWriteAttributeListWithListOfOctetString_174(); - break; - case 175: - ChipLogProgress(chipTool, " ***** Test Step 175 : Read attribute LIST With List of OCTET_STRING\n"); - err = TestReadAttributeListWithListOfOctetString_175(); - break; - case 176: - ChipLogProgress(chipTool, " ***** Test Step 176 : Write attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); - err = TestWriteAttributeListWithListOfListStructOctetString_176(); - break; - case 177: - ChipLogProgress(chipTool, " ***** Test Step 177 : Read attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); - err = TestReadAttributeListWithListOfListStructOctetString_177(); - break; - case 178: - ChipLogProgress(chipTool, " ***** Test Step 178 : Send Test Command with optional arg set.\n"); - err = TestSendTestCommandWithOptionalArgSet_178(); - break; - case 179: - ChipLogProgress(chipTool, " ***** Test Step 179 : Send Test Command without its optional arg.\n"); - err = TestSendTestCommandWithoutItsOptionalArg_179(); - break; - case 180: - ChipLogProgress(chipTool, " ***** Test Step 180 : Read list of structs containing nullables and optionals\n"); - err = TestReadListOfStructsContainingNullablesAndOptionals_180(); - break; - case 181: - ChipLogProgress(chipTool, " ***** Test Step 181 : Write list of structs containing nullables and optionals\n"); - err = TestWriteListOfStructsContainingNullablesAndOptionals_181(); - break; - case 182: - ChipLogProgress(chipTool, " ***** Test Step 182 : Read list of structs containing nullables and optionals after writing\n"); - err = TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_182(); - break; - case 183: - ChipLogProgress(chipTool, " ***** Test Step 183 : Write attribute NULLABLE_BOOLEAN null\n"); - err = TestWriteAttributeNullableBooleanNull_183(); - break; - case 184: - ChipLogProgress(chipTool, " ***** Test Step 184 : Read attribute NULLABLE_BOOLEAN null\n"); - err = TestReadAttributeNullableBooleanNull_184(); - break; - case 185: - ChipLogProgress(chipTool, " ***** Test Step 185 : Write attribute NULLABLE_BOOLEAN True\n"); - err = TestWriteAttributeNullableBooleanTrue_185(); - break; - case 186: - ChipLogProgress(chipTool, " ***** Test Step 186 : Read attribute NULLABLE_BOOLEAN True\n"); - err = TestReadAttributeNullableBooleanTrue_186(); - break; - case 187: - ChipLogProgress(chipTool, " ***** Test Step 187 : Read attribute NULLABLE_BOOLEAN not null\n"); - err = TestReadAttributeNullableBooleanNotNull_187(); - break; - case 188: - ChipLogProgress(chipTool, " ***** Test Step 188 : Write attribute NULLABLE_BITMAP8 Max Value\n"); - err = TestWriteAttributeNullableBitmap8MaxValue_188(); - break; - case 189: - ChipLogProgress(chipTool, " ***** Test Step 189 : Read attribute NULLABLE_BITMAP8 Max Value\n"); - err = TestReadAttributeNullableBitmap8MaxValue_189(); - break; - case 190: - ChipLogProgress(chipTool, " ***** Test Step 190 : Write attribute NULLABLE_BITMAP8 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap8InvalidValue_190(); - break; - case 191: - ChipLogProgress(chipTool, " ***** Test Step 191 : Read attribute NULLABLE_BITMAP8 unchanged Value\n"); - err = TestReadAttributeNullableBitmap8UnchangedValue_191(); - break; - case 192: - ChipLogProgress(chipTool, " ***** Test Step 192 : Write attribute NULLABLE_BITMAP8 null Value\n"); - err = TestWriteAttributeNullableBitmap8NullValue_192(); - break; - case 193: - ChipLogProgress(chipTool, " ***** Test Step 193 : Read attribute NULLABLE_BITMAP8 null Value\n"); - err = TestReadAttributeNullableBitmap8NullValue_193(); - break; - case 194: - ChipLogProgress(chipTool, " ***** Test Step 194 : Read attribute NULLABLE_BITMAP8 not 254 Value\n"); - err = TestReadAttributeNullableBitmap8Not254Value_194(); - break; - case 195: - ChipLogProgress(chipTool, " ***** Test Step 195 : Write attribute NULLABLE_BITMAP16 Max Value\n"); - err = TestWriteAttributeNullableBitmap16MaxValue_195(); - break; - case 196: - ChipLogProgress(chipTool, " ***** Test Step 196 : Read attribute NULLABLE_BITMAP16 Max Value\n"); - err = TestReadAttributeNullableBitmap16MaxValue_196(); - break; - case 197: - ChipLogProgress(chipTool, " ***** Test Step 197 : Write attribute NULLABLE_BITMAP16 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap16InvalidValue_197(); - break; - case 198: - ChipLogProgress(chipTool, " ***** Test Step 198 : Read attribute NULLABLE_BITMAP16 unchanged Value\n"); - err = TestReadAttributeNullableBitmap16UnchangedValue_198(); - break; - case 199: - ChipLogProgress(chipTool, " ***** Test Step 199 : Write attribute NULLABLE_BITMAP16 null Value\n"); - err = TestWriteAttributeNullableBitmap16NullValue_199(); - break; - case 200: - ChipLogProgress(chipTool, " ***** Test Step 200 : Read attribute NULLABLE_BITMAP16 null Value\n"); - err = TestReadAttributeNullableBitmap16NullValue_200(); - break; - case 201: - ChipLogProgress(chipTool, " ***** Test Step 201 : Write attribute NULLABLE_BITMAP32 Max Value\n"); - err = TestWriteAttributeNullableBitmap32MaxValue_201(); - break; - case 202: - ChipLogProgress(chipTool, " ***** Test Step 202 : Read attribute NULLABLE_BITMAP32 Max Value\n"); - err = TestReadAttributeNullableBitmap32MaxValue_202(); - break; - case 203: - ChipLogProgress(chipTool, " ***** Test Step 203 : Write attribute NULLABLE_BITMAP32 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap32InvalidValue_203(); - break; - case 204: - ChipLogProgress(chipTool, " ***** Test Step 204 : Read attribute NULLABLE_BITMAP32 unchanged Value\n"); - err = TestReadAttributeNullableBitmap32UnchangedValue_204(); - break; - case 205: - ChipLogProgress(chipTool, " ***** Test Step 205 : Write attribute NULLABLE_BITMAP32 null Value\n"); - err = TestWriteAttributeNullableBitmap32NullValue_205(); - break; - case 206: - ChipLogProgress(chipTool, " ***** Test Step 206 : Read attribute NULLABLE_BITMAP32 null Value\n"); - err = TestReadAttributeNullableBitmap32NullValue_206(); - break; - case 207: - ChipLogProgress(chipTool, " ***** Test Step 207 : Write attribute NULLABLE_BITMAP64 Max Value\n"); - err = TestWriteAttributeNullableBitmap64MaxValue_207(); - break; - case 208: - ChipLogProgress(chipTool, " ***** Test Step 208 : Read attribute NULLABLE_BITMAP64 Max Value\n"); - err = TestReadAttributeNullableBitmap64MaxValue_208(); - break; - case 209: - ChipLogProgress(chipTool, " ***** Test Step 209 : Write attribute NULLABLE_BITMAP64 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap64InvalidValue_209(); - break; - case 210: - ChipLogProgress(chipTool, " ***** Test Step 210 : Read attribute NULLABLE_BITMAP64 unchanged Value\n"); - err = TestReadAttributeNullableBitmap64UnchangedValue_210(); - break; - case 211: - ChipLogProgress(chipTool, " ***** Test Step 211 : Write attribute NULLABLE_BITMAP64 null Value\n"); - err = TestWriteAttributeNullableBitmap64NullValue_211(); - break; - case 212: - ChipLogProgress(chipTool, " ***** Test Step 212 : Read attribute NULLABLE_BITMAP64 null Value\n"); - err = TestReadAttributeNullableBitmap64NullValue_212(); - break; - case 213: - ChipLogProgress(chipTool, " ***** Test Step 213 : Write attribute NULLABLE_INT8U Min Value\n"); - err = TestWriteAttributeNullableInt8uMinValue_213(); - break; - case 214: - ChipLogProgress(chipTool, " ***** Test Step 214 : Read attribute NULLABLE_INT8U Min Value\n"); - err = TestReadAttributeNullableInt8uMinValue_214(); - break; - case 215: - ChipLogProgress(chipTool, " ***** Test Step 215 : Write attribute NULLABLE_INT8U Max Value\n"); - err = TestWriteAttributeNullableInt8uMaxValue_215(); - break; - case 216: - ChipLogProgress(chipTool, " ***** Test Step 216 : Read attribute NULLABLE_INT8U Max Value\n"); - err = TestReadAttributeNullableInt8uMaxValue_216(); - break; - case 217: - ChipLogProgress(chipTool, " ***** Test Step 217 : Write attribute NULLABLE_INT8U Invalid Value\n"); - err = TestWriteAttributeNullableInt8uInvalidValue_217(); - break; - case 218: - ChipLogProgress(chipTool, " ***** Test Step 218 : Read attribute NULLABLE_INT8U unchanged Value\n"); - err = TestReadAttributeNullableInt8uUnchangedValue_218(); - break; - case 219: - ChipLogProgress(chipTool, " ***** Test Step 219 : Read attribute NULLABLE_INT8U unchanged Value with constraint\n"); - err = TestReadAttributeNullableInt8uUnchangedValueWithConstraint_219(); - break; - case 220: - ChipLogProgress(chipTool, " ***** Test Step 220 : Write attribute NULLABLE_INT8U null Value\n"); - err = TestWriteAttributeNullableInt8uNullValue_220(); - break; - case 221: - ChipLogProgress(chipTool, " ***** Test Step 221 : Read attribute NULLABLE_INT8U null Value\n"); - err = TestReadAttributeNullableInt8uNullValue_221(); - break; - case 222: - ChipLogProgress(chipTool, " ***** Test Step 222 : Read attribute NULLABLE_INT8U null Value & range\n"); - err = TestReadAttributeNullableInt8uNullValueRange_222(); - break; - case 223: - ChipLogProgress(chipTool, " ***** Test Step 223 : Read attribute NULLABLE_INT8U null Value & not\n"); - err = TestReadAttributeNullableInt8uNullValueNot_223(); - break; - case 224: - ChipLogProgress(chipTool, " ***** Test Step 224 : Write attribute NULLABLE_INT8U Value\n"); - err = TestWriteAttributeNullableInt8uValue_224(); - break; - case 225: - ChipLogProgress(chipTool, " ***** Test Step 225 : Read attribute NULLABLE_INT8U Value in range\n"); - err = TestReadAttributeNullableInt8uValueInRange_225(); - break; - case 226: - ChipLogProgress(chipTool, " ***** Test Step 226 : Read attribute NULLABLE_INT8U notValue OK\n"); - err = TestReadAttributeNullableInt8uNotValueOk_226(); - break; - case 227: - ChipLogProgress(chipTool, " ***** Test Step 227 : Write attribute NULLABLE_INT16U Min Value\n"); - err = TestWriteAttributeNullableInt16uMinValue_227(); - break; - case 228: - ChipLogProgress(chipTool, " ***** Test Step 228 : Read attribute NULLABLE_INT16U Min Value\n"); - err = TestReadAttributeNullableInt16uMinValue_228(); - break; - case 229: - ChipLogProgress(chipTool, " ***** Test Step 229 : Write attribute NULLABLE_INT16U Max Value\n"); - err = TestWriteAttributeNullableInt16uMaxValue_229(); - break; - case 230: - ChipLogProgress(chipTool, " ***** Test Step 230 : Read attribute NULLABLE_INT16U Max Value\n"); - err = TestReadAttributeNullableInt16uMaxValue_230(); - break; - case 231: - ChipLogProgress(chipTool, " ***** Test Step 231 : Write attribute NULLABLE_INT16U Invalid Value\n"); - err = TestWriteAttributeNullableInt16uInvalidValue_231(); - break; - case 232: - ChipLogProgress(chipTool, " ***** Test Step 232 : Read attribute NULLABLE_INT16U unchanged Value\n"); - err = TestReadAttributeNullableInt16uUnchangedValue_232(); - break; - case 233: - ChipLogProgress(chipTool, " ***** Test Step 233 : Write attribute NULLABLE_INT16U null Value\n"); - err = TestWriteAttributeNullableInt16uNullValue_233(); - break; - case 234: - ChipLogProgress(chipTool, " ***** Test Step 234 : Read attribute NULLABLE_INT16U null Value\n"); - err = TestReadAttributeNullableInt16uNullValue_234(); - break; - case 235: - ChipLogProgress(chipTool, " ***** Test Step 235 : Read attribute NULLABLE_INT16U null Value & range\n"); - err = TestReadAttributeNullableInt16uNullValueRange_235(); - break; - case 236: - ChipLogProgress(chipTool, " ***** Test Step 236 : Read attribute NULLABLE_INT16U null Value & not\n"); - err = TestReadAttributeNullableInt16uNullValueNot_236(); - break; - case 237: - ChipLogProgress(chipTool, " ***** Test Step 237 : Write attribute NULLABLE_INT16U Value\n"); - err = TestWriteAttributeNullableInt16uValue_237(); - break; - case 238: - ChipLogProgress(chipTool, " ***** Test Step 238 : Read attribute NULLABLE_INT16U Value in range\n"); - err = TestReadAttributeNullableInt16uValueInRange_238(); - break; - case 239: - ChipLogProgress(chipTool, " ***** Test Step 239 : Read attribute NULLABLE_INT16U notValue OK\n"); - err = TestReadAttributeNullableInt16uNotValueOk_239(); - break; - case 240: - ChipLogProgress(chipTool, " ***** Test Step 240 : Write attribute NULLABLE_INT32U Min Value\n"); - err = TestWriteAttributeNullableInt32uMinValue_240(); - break; - case 241: - ChipLogProgress(chipTool, " ***** Test Step 241 : Read attribute NULLABLE_INT32U Min Value\n"); - err = TestReadAttributeNullableInt32uMinValue_241(); - break; - case 242: - ChipLogProgress(chipTool, " ***** Test Step 242 : Write attribute NULLABLE_INT32U Max Value\n"); - err = TestWriteAttributeNullableInt32uMaxValue_242(); - break; - case 243: - ChipLogProgress(chipTool, " ***** Test Step 243 : Read attribute NULLABLE_INT32U Max Value\n"); - err = TestReadAttributeNullableInt32uMaxValue_243(); - break; - case 244: - ChipLogProgress(chipTool, " ***** Test Step 244 : Write attribute NULLABLE_INT32U Invalid Value\n"); - err = TestWriteAttributeNullableInt32uInvalidValue_244(); - break; - case 245: - ChipLogProgress(chipTool, " ***** Test Step 245 : Read attribute NULLABLE_INT32U unchanged Value\n"); - err = TestReadAttributeNullableInt32uUnchangedValue_245(); - break; - case 246: - ChipLogProgress(chipTool, " ***** Test Step 246 : Write attribute NULLABLE_INT32U null Value\n"); - err = TestWriteAttributeNullableInt32uNullValue_246(); - break; - case 247: - ChipLogProgress(chipTool, " ***** Test Step 247 : Read attribute NULLABLE_INT32U null Value\n"); - err = TestReadAttributeNullableInt32uNullValue_247(); - break; - case 248: - ChipLogProgress(chipTool, " ***** Test Step 248 : Read attribute NULLABLE_INT32U null Value & range\n"); - err = TestReadAttributeNullableInt32uNullValueRange_248(); - break; - case 249: - ChipLogProgress(chipTool, " ***** Test Step 249 : Read attribute NULLABLE_INT32U null Value & not\n"); - err = TestReadAttributeNullableInt32uNullValueNot_249(); - break; - case 250: - ChipLogProgress(chipTool, " ***** Test Step 250 : Write attribute NULLABLE_INT32U Value\n"); - err = TestWriteAttributeNullableInt32uValue_250(); - break; - case 251: - ChipLogProgress(chipTool, " ***** Test Step 251 : Read attribute NULLABLE_INT32U Value in range\n"); - err = TestReadAttributeNullableInt32uValueInRange_251(); - break; - case 252: - ChipLogProgress(chipTool, " ***** Test Step 252 : Read attribute NULLABLE_INT32U notValue OK\n"); - err = TestReadAttributeNullableInt32uNotValueOk_252(); - break; - case 253: - ChipLogProgress(chipTool, " ***** Test Step 253 : Write attribute NULLABLE_INT64U Min Value\n"); - err = TestWriteAttributeNullableInt64uMinValue_253(); - break; - case 254: - ChipLogProgress(chipTool, " ***** Test Step 254 : Read attribute NULLABLE_INT64U Min Value\n"); - err = TestReadAttributeNullableInt64uMinValue_254(); - break; - case 255: - ChipLogProgress(chipTool, " ***** Test Step 255 : Write attribute NULLABLE_INT64U Max Value\n"); - err = TestWriteAttributeNullableInt64uMaxValue_255(); - break; - case 256: - ChipLogProgress(chipTool, " ***** Test Step 256 : Read attribute NULLABLE_INT64U Max Value\n"); - err = TestReadAttributeNullableInt64uMaxValue_256(); - break; - case 257: - ChipLogProgress(chipTool, " ***** Test Step 257 : Write attribute NULLABLE_INT64U Invalid Value\n"); - err = TestWriteAttributeNullableInt64uInvalidValue_257(); - break; - case 258: - ChipLogProgress(chipTool, " ***** Test Step 258 : Read attribute NULLABLE_INT64U unchanged Value\n"); - err = TestReadAttributeNullableInt64uUnchangedValue_258(); - break; - case 259: - ChipLogProgress(chipTool, " ***** Test Step 259 : Write attribute NULLABLE_INT64U null Value\n"); - err = TestWriteAttributeNullableInt64uNullValue_259(); - break; - case 260: - ChipLogProgress(chipTool, " ***** Test Step 260 : Read attribute NULLABLE_INT64U null Value\n"); - err = TestReadAttributeNullableInt64uNullValue_260(); - break; - case 261: - ChipLogProgress(chipTool, " ***** Test Step 261 : Read attribute NULLABLE_INT64U null Value & range\n"); - err = TestReadAttributeNullableInt64uNullValueRange_261(); - break; - case 262: - ChipLogProgress(chipTool, " ***** Test Step 262 : Read attribute NULLABLE_INT64U null Value & not\n"); - err = TestReadAttributeNullableInt64uNullValueNot_262(); - break; - case 263: - ChipLogProgress(chipTool, " ***** Test Step 263 : Write attribute NULLABLE_INT64U Value\n"); - err = TestWriteAttributeNullableInt64uValue_263(); - break; - case 264: - ChipLogProgress(chipTool, " ***** Test Step 264 : Read attribute NULLABLE_INT64U Value in range\n"); - err = TestReadAttributeNullableInt64uValueInRange_264(); - break; - case 265: - ChipLogProgress(chipTool, " ***** Test Step 265 : Read attribute NULLABLE_INT64U notValue OK\n"); - err = TestReadAttributeNullableInt64uNotValueOk_265(); - break; - case 266: - ChipLogProgress(chipTool, " ***** Test Step 266 : Write attribute NULLABLE_INT8S Min Value\n"); - err = TestWriteAttributeNullableInt8sMinValue_266(); - break; - case 267: - ChipLogProgress(chipTool, " ***** Test Step 267 : Read attribute NULLABLE_INT8S Min Value\n"); - err = TestReadAttributeNullableInt8sMinValue_267(); - break; - case 268: - ChipLogProgress(chipTool, " ***** Test Step 268 : Write attribute NULLABLE_INT8S Invalid Value\n"); - err = TestWriteAttributeNullableInt8sInvalidValue_268(); - break; - case 269: - ChipLogProgress(chipTool, " ***** Test Step 269 : Read attribute NULLABLE_INT8S unchanged Value\n"); - err = TestReadAttributeNullableInt8sUnchangedValue_269(); - break; - case 270: - ChipLogProgress(chipTool, " ***** Test Step 270 : Write attribute NULLABLE_INT8S null Value\n"); - err = TestWriteAttributeNullableInt8sNullValue_270(); - break; - case 271: - ChipLogProgress(chipTool, " ***** Test Step 271 : Read attribute NULLABLE_INT8S null Value\n"); - err = TestReadAttributeNullableInt8sNullValue_271(); - break; - case 272: - ChipLogProgress(chipTool, " ***** Test Step 272 : Read attribute NULLABLE_INT8S null Value & range\n"); - err = TestReadAttributeNullableInt8sNullValueRange_272(); - break; - case 273: - ChipLogProgress(chipTool, " ***** Test Step 273 : Read attribute NULLABLE_INT8S null Value & not\n"); - err = TestReadAttributeNullableInt8sNullValueNot_273(); - break; - case 274: - ChipLogProgress(chipTool, " ***** Test Step 274 : Write attribute NULLABLE_INT8S Value\n"); - err = TestWriteAttributeNullableInt8sValue_274(); - break; - case 275: - ChipLogProgress(chipTool, " ***** Test Step 275 : Read attribute NULLABLE_INT8S Value in range\n"); - err = TestReadAttributeNullableInt8sValueInRange_275(); - break; - case 276: - ChipLogProgress(chipTool, " ***** Test Step 276 : Read attribute NULLABLE_INT8S notValue OK\n"); - err = TestReadAttributeNullableInt8sNotValueOk_276(); - break; - case 277: - ChipLogProgress(chipTool, " ***** Test Step 277 : Write attribute NULLABLE_INT16S Min Value\n"); - err = TestWriteAttributeNullableInt16sMinValue_277(); - break; - case 278: - ChipLogProgress(chipTool, " ***** Test Step 278 : Read attribute NULLABLE_INT16S Min Value\n"); - err = TestReadAttributeNullableInt16sMinValue_278(); - break; - case 279: - ChipLogProgress(chipTool, " ***** Test Step 279 : Write attribute NULLABLE_INT16S Invalid Value\n"); - err = TestWriteAttributeNullableInt16sInvalidValue_279(); - break; - case 280: - ChipLogProgress(chipTool, " ***** Test Step 280 : Read attribute NULLABLE_INT16S unchanged Value\n"); - err = TestReadAttributeNullableInt16sUnchangedValue_280(); - break; - case 281: - ChipLogProgress(chipTool, " ***** Test Step 281 : Write attribute NULLABLE_INT16S null Value\n"); - err = TestWriteAttributeNullableInt16sNullValue_281(); - break; - case 282: - ChipLogProgress(chipTool, " ***** Test Step 282 : Read attribute NULLABLE_INT16S null Value\n"); - err = TestReadAttributeNullableInt16sNullValue_282(); - break; - case 283: - ChipLogProgress(chipTool, " ***** Test Step 283 : Read attribute NULLABLE_INT16S null Value & range\n"); - err = TestReadAttributeNullableInt16sNullValueRange_283(); - break; - case 284: - ChipLogProgress(chipTool, " ***** Test Step 284 : Read attribute NULLABLE_INT16S null Value & not\n"); - err = TestReadAttributeNullableInt16sNullValueNot_284(); - break; - case 285: - ChipLogProgress(chipTool, " ***** Test Step 285 : Write attribute NULLABLE_INT16S Value\n"); - err = TestWriteAttributeNullableInt16sValue_285(); - break; - case 286: - ChipLogProgress(chipTool, " ***** Test Step 286 : Read attribute NULLABLE_INT16S Value in range\n"); - err = TestReadAttributeNullableInt16sValueInRange_286(); - break; - case 287: - ChipLogProgress(chipTool, " ***** Test Step 287 : Read attribute NULLABLE_INT16S notValue OK\n"); - err = TestReadAttributeNullableInt16sNotValueOk_287(); - break; - case 288: - ChipLogProgress(chipTool, " ***** Test Step 288 : Write attribute NULLABLE_INT32S Min Value\n"); - err = TestWriteAttributeNullableInt32sMinValue_288(); - break; - case 289: - ChipLogProgress(chipTool, " ***** Test Step 289 : Read attribute NULLABLE_INT32S Min Value\n"); - err = TestReadAttributeNullableInt32sMinValue_289(); - break; - case 290: - ChipLogProgress(chipTool, " ***** Test Step 290 : Write attribute NULLABLE_INT32S Invalid Value\n"); - err = TestWriteAttributeNullableInt32sInvalidValue_290(); - break; - case 291: - ChipLogProgress(chipTool, " ***** Test Step 291 : Read attribute NULLABLE_INT32S unchanged Value\n"); - err = TestReadAttributeNullableInt32sUnchangedValue_291(); - break; - case 292: - ChipLogProgress(chipTool, " ***** Test Step 292 : Write attribute NULLABLE_INT32S null Value\n"); - err = TestWriteAttributeNullableInt32sNullValue_292(); - break; - case 293: - ChipLogProgress(chipTool, " ***** Test Step 293 : Read attribute NULLABLE_INT32S null Value\n"); - err = TestReadAttributeNullableInt32sNullValue_293(); - break; - case 294: - ChipLogProgress(chipTool, " ***** Test Step 294 : Read attribute NULLABLE_INT32S null Value & range\n"); - err = TestReadAttributeNullableInt32sNullValueRange_294(); - break; - case 295: - ChipLogProgress(chipTool, " ***** Test Step 295 : Read attribute NULLABLE_INT32S null Value & not\n"); - err = TestReadAttributeNullableInt32sNullValueNot_295(); - break; - case 296: - ChipLogProgress(chipTool, " ***** Test Step 296 : Write attribute NULLABLE_INT32S Value\n"); - err = TestWriteAttributeNullableInt32sValue_296(); - break; - case 297: - ChipLogProgress(chipTool, " ***** Test Step 297 : Read attribute NULLABLE_INT32S Value in range\n"); - err = TestReadAttributeNullableInt32sValueInRange_297(); - break; - case 298: - ChipLogProgress(chipTool, " ***** Test Step 298 : Read attribute NULLABLE_INT32S notValue OK\n"); - err = TestReadAttributeNullableInt32sNotValueOk_298(); - break; - case 299: - ChipLogProgress(chipTool, " ***** Test Step 299 : Write attribute NULLABLE_INT64S Min Value\n"); - err = TestWriteAttributeNullableInt64sMinValue_299(); - break; - case 300: - ChipLogProgress(chipTool, " ***** Test Step 300 : Read attribute NULLABLE_INT64S Min Value\n"); - err = TestReadAttributeNullableInt64sMinValue_300(); - break; - case 301: - ChipLogProgress(chipTool, " ***** Test Step 301 : Write attribute NULLABLE_INT64S Invalid Value\n"); - err = TestWriteAttributeNullableInt64sInvalidValue_301(); - break; - case 302: - ChipLogProgress(chipTool, " ***** Test Step 302 : Read attribute NULLABLE_INT64S unchanged Value\n"); - err = TestReadAttributeNullableInt64sUnchangedValue_302(); - break; - case 303: - ChipLogProgress(chipTool, " ***** Test Step 303 : Write attribute NULLABLE_INT64S null Value\n"); - err = TestWriteAttributeNullableInt64sNullValue_303(); - break; - case 304: - ChipLogProgress(chipTool, " ***** Test Step 304 : Read attribute NULLABLE_INT64S null Value\n"); - err = TestReadAttributeNullableInt64sNullValue_304(); - break; - case 305: - ChipLogProgress(chipTool, " ***** Test Step 305 : Read attribute NULLABLE_INT64S null Value & range\n"); - err = TestReadAttributeNullableInt64sNullValueRange_305(); - break; - case 306: - ChipLogProgress(chipTool, " ***** Test Step 306 : Read attribute NULLABLE_INT64S null Value & not\n"); - err = TestReadAttributeNullableInt64sNullValueNot_306(); - break; - case 307: - ChipLogProgress(chipTool, " ***** Test Step 307 : Write attribute NULLABLE_INT64S Value\n"); - err = TestWriteAttributeNullableInt64sValue_307(); - break; - case 308: - ChipLogProgress(chipTool, " ***** Test Step 308 : Read attribute NULLABLE_INT64S Value in range\n"); - err = TestReadAttributeNullableInt64sValueInRange_308(); - break; - case 309: - ChipLogProgress(chipTool, " ***** Test Step 309 : Read attribute NULLABLE_INT64S notValue OK\n"); - err = TestReadAttributeNullableInt64sNotValueOk_309(); - break; - case 310: - ChipLogProgress(chipTool, " ***** Test Step 310 : Write attribute NULLABLE_SINGLE medium Value\n"); - err = TestWriteAttributeNullableSingleMediumValue_310(); - break; - case 311: - ChipLogProgress(chipTool, " ***** Test Step 311 : Read attribute NULLABLE_SINGLE medium Value\n"); - err = TestReadAttributeNullableSingleMediumValue_311(); - break; - case 312: - ChipLogProgress(chipTool, " ***** Test Step 312 : Write attribute NULLABLE_SINGLE largest Value\n"); - err = TestWriteAttributeNullableSingleLargestValue_312(); - break; - case 313: - ChipLogProgress(chipTool, " ***** Test Step 313 : Read attribute NULLABLE_SINGLE largest Value\n"); - err = TestReadAttributeNullableSingleLargestValue_313(); - break; - case 314: - ChipLogProgress(chipTool, " ***** Test Step 314 : Write attribute NULLABLE_SINGLE smallest Value\n"); - err = TestWriteAttributeNullableSingleSmallestValue_314(); - break; - case 315: - ChipLogProgress(chipTool, " ***** Test Step 315 : Read attribute NULLABLE_SINGLE smallest Value\n"); - err = TestReadAttributeNullableSingleSmallestValue_315(); - break; - case 316: - ChipLogProgress(chipTool, " ***** Test Step 316 : Write attribute NULLABLE_SINGLE null Value\n"); - err = TestWriteAttributeNullableSingleNullValue_316(); - break; - case 317: - ChipLogProgress(chipTool, " ***** Test Step 317 : Read attribute NULLABLE_SINGLE null Value\n"); - err = TestReadAttributeNullableSingleNullValue_317(); - break; - case 318: - ChipLogProgress(chipTool, " ***** Test Step 318 : Write attribute NULLABLE_SINGLE 0 Value\n"); - err = TestWriteAttributeNullableSingle0Value_318(); - break; - case 319: - ChipLogProgress(chipTool, " ***** Test Step 319 : Read attribute NULLABLE_SINGLE 0 Value\n"); - err = TestReadAttributeNullableSingle0Value_319(); - break; - case 320: - ChipLogProgress(chipTool, " ***** Test Step 320 : Write attribute NULLABLE_DOUBLE medium Value\n"); - err = TestWriteAttributeNullableDoubleMediumValue_320(); - break; - case 321: - ChipLogProgress(chipTool, " ***** Test Step 321 : Read attribute NULLABLE_DOUBLE medium Value\n"); - err = TestReadAttributeNullableDoubleMediumValue_321(); - break; - case 322: - ChipLogProgress(chipTool, " ***** Test Step 322 : Write attribute NULLABLE_DOUBLE largest Value\n"); - err = TestWriteAttributeNullableDoubleLargestValue_322(); - break; - case 323: - ChipLogProgress(chipTool, " ***** Test Step 323 : Read attribute NULLABLE_DOUBLE largest Value\n"); - err = TestReadAttributeNullableDoubleLargestValue_323(); - break; - case 324: - ChipLogProgress(chipTool, " ***** Test Step 324 : Write attribute NULLABLE_DOUBLE smallest Value\n"); - err = TestWriteAttributeNullableDoubleSmallestValue_324(); - break; - case 325: - ChipLogProgress(chipTool, " ***** Test Step 325 : Read attribute NULLABLE_DOUBLE smallest Value\n"); - err = TestReadAttributeNullableDoubleSmallestValue_325(); - break; - case 326: - ChipLogProgress(chipTool, " ***** Test Step 326 : Write attribute NULLABLE_DOUBLE null Value\n"); - err = TestWriteAttributeNullableDoubleNullValue_326(); - break; - case 327: - ChipLogProgress(chipTool, " ***** Test Step 327 : Read attribute NULLABLE_DOUBLE null Value\n"); - err = TestReadAttributeNullableDoubleNullValue_327(); - break; - case 328: - ChipLogProgress(chipTool, " ***** Test Step 328 : Write attribute NULLABLE_DOUBLE 0 Value\n"); - err = TestWriteAttributeNullableDouble0Value_328(); - break; - case 329: - ChipLogProgress(chipTool, " ***** Test Step 329 : Read attribute NULLABLE_DOUBLE 0 Value\n"); - err = TestReadAttributeNullableDouble0Value_329(); - break; - case 330: - ChipLogProgress(chipTool, " ***** Test Step 330 : Write attribute NULLABLE_ENUM8 Min Value\n"); - err = TestWriteAttributeNullableEnum8MinValue_330(); - break; - case 331: - ChipLogProgress(chipTool, " ***** Test Step 331 : Read attribute NULLABLE_ENUM8 Min Value\n"); - err = TestReadAttributeNullableEnum8MinValue_331(); - break; - case 332: - ChipLogProgress(chipTool, " ***** Test Step 332 : Write attribute NULLABLE_ENUM8 Max Value\n"); - err = TestWriteAttributeNullableEnum8MaxValue_332(); - break; - case 333: - ChipLogProgress(chipTool, " ***** Test Step 333 : Read attribute NULLABLE_ENUM8 Max Value\n"); - err = TestReadAttributeNullableEnum8MaxValue_333(); - break; - case 334: - ChipLogProgress(chipTool, " ***** Test Step 334 : Write attribute NULLABLE_ENUM8 Invalid Value\n"); - err = TestWriteAttributeNullableEnum8InvalidValue_334(); - break; - case 335: - ChipLogProgress(chipTool, " ***** Test Step 335 : Read attribute NULLABLE_ENUM8 unchanged Value\n"); - err = TestReadAttributeNullableEnum8UnchangedValue_335(); - break; - case 336: - ChipLogProgress(chipTool, " ***** Test Step 336 : Write attribute NULLABLE_ENUM8 null Value\n"); - err = TestWriteAttributeNullableEnum8NullValue_336(); - break; - case 337: - ChipLogProgress(chipTool, " ***** Test Step 337 : Read attribute NULLABLE_ENUM8 null Value\n"); - err = TestReadAttributeNullableEnum8NullValue_337(); - break; - case 338: - ChipLogProgress(chipTool, " ***** Test Step 338 : Write attribute NULLABLE_ENUM16 Min Value\n"); - err = TestWriteAttributeNullableEnum16MinValue_338(); - break; - case 339: - ChipLogProgress(chipTool, " ***** Test Step 339 : Read attribute NULLABLE_ENUM16 Min Value\n"); - err = TestReadAttributeNullableEnum16MinValue_339(); - break; - case 340: - ChipLogProgress(chipTool, " ***** Test Step 340 : Write attribute NULLABLE_ENUM16 Max Value\n"); - err = TestWriteAttributeNullableEnum16MaxValue_340(); - break; - case 341: - ChipLogProgress(chipTool, " ***** Test Step 341 : Read attribute NULLABLE_ENUM16 Max Value\n"); - err = TestReadAttributeNullableEnum16MaxValue_341(); - break; - case 342: - ChipLogProgress(chipTool, " ***** Test Step 342 : Write attribute NULLABLE_ENUM16 Invalid Value\n"); - err = TestWriteAttributeNullableEnum16InvalidValue_342(); - break; - case 343: - ChipLogProgress(chipTool, " ***** Test Step 343 : Read attribute NULLABLE_ENUM16 unchanged Value\n"); - err = TestReadAttributeNullableEnum16UnchangedValue_343(); - break; - case 344: - ChipLogProgress(chipTool, " ***** Test Step 344 : Write attribute NULLABLE_ENUM16 null Value\n"); - err = TestWriteAttributeNullableEnum16NullValue_344(); - break; - case 345: - ChipLogProgress(chipTool, " ***** Test Step 345 : Read attribute NULLABLE_ENUM16 null Value\n"); - err = TestReadAttributeNullableEnum16NullValue_345(); - break; - case 346: - ChipLogProgress(chipTool, " ***** Test Step 346 : Write attribute NULLABLE_SIMPLE_ENUM Min Value\n"); - err = TestWriteAttributeNullableSimpleEnumMinValue_346(); - break; - case 347: - ChipLogProgress(chipTool, " ***** Test Step 347 : Read attribute NULLABLE_SIMPLE_ENUM Min Value\n"); - err = TestReadAttributeNullableSimpleEnumMinValue_347(); - break; - case 348: - ChipLogProgress(chipTool, " ***** Test Step 348 : Write attribute NULLABLE_SIMPLE_ENUM Max Value\n"); - err = TestWriteAttributeNullableSimpleEnumMaxValue_348(); - break; - case 349: - ChipLogProgress(chipTool, " ***** Test Step 349 : Read attribute NULLABLE_SIMPLE_ENUM Max Value\n"); - err = TestReadAttributeNullableSimpleEnumMaxValue_349(); - break; - case 350: - ChipLogProgress(chipTool, " ***** Test Step 350 : Write attribute NULLABLE_SIMPLE_ENUM Invalid Value\n"); - err = TestWriteAttributeNullableSimpleEnumInvalidValue_350(); - break; - case 351: - ChipLogProgress(chipTool, " ***** Test Step 351 : Read attribute NULLABLE_SIMPLE_ENUM unchanged Value\n"); - err = TestReadAttributeNullableSimpleEnumUnchangedValue_351(); - break; - case 352: - ChipLogProgress(chipTool, " ***** Test Step 352 : Write attribute NULLABLE_SIMPLE_ENUM null Value\n"); - err = TestWriteAttributeNullableSimpleEnumNullValue_352(); - break; - case 353: - ChipLogProgress(chipTool, " ***** Test Step 353 : Read attribute NULLABLE_SIMPLE_ENUM null Value\n"); - err = TestReadAttributeNullableSimpleEnumNullValue_353(); - break; - case 354: - ChipLogProgress(chipTool, " ***** Test Step 354 : Read attribute NULLABLE_SIMPLE_ENUM not 3 Value\n"); - err = TestReadAttributeNullableSimpleEnumNot3Value_354(); - break; - case 355: - ChipLogProgress(chipTool, " ***** Test Step 355 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); - err = TestReadAttributeNullableOctetStringDefaultValue_355(); - break; - case 356: - ChipLogProgress(chipTool, " ***** Test Step 356 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_356(); - break; - case 357: - ChipLogProgress(chipTool, " ***** Test Step 357 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_357(); - break; - case 358: - ChipLogProgress(chipTool, " ***** Test Step 358 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_358(); - break; - case 359: - ChipLogProgress(chipTool, " ***** Test Step 359 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_359(); - break; - case 360: - ChipLogProgress(chipTool, " ***** Test Step 360 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_360(); - break; - case 361: - ChipLogProgress(chipTool, " ***** Test Step 361 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_361(); - break; - case 362: - ChipLogProgress(chipTool, " ***** Test Step 362 : Read attribute NULLABLE_OCTET_STRING not TestValue\n"); - err = TestReadAttributeNullableOctetStringNotTestValue_362(); - break; - case 363: - ChipLogProgress(chipTool, " ***** Test Step 363 : Read attribute NULLABLE_CHAR_STRING Default Value\n"); - err = TestReadAttributeNullableCharStringDefaultValue_363(); - break; - case 364: - ChipLogProgress(chipTool, " ***** Test Step 364 : Write attribute NULLABLE_CHAR_STRING\n"); - err = TestWriteAttributeNullableCharString_364(); - break; - case 365: - ChipLogProgress(chipTool, " ***** Test Step 365 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_365(); - break; - case 366: - ChipLogProgress(chipTool, " ***** Test Step 366 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_366(); - break; - case 367: - ChipLogProgress(chipTool, " ***** Test Step 367 : Write attribute NULLABLE_CHAR_STRING - Value too long\n"); - err = TestWriteAttributeNullableCharStringValueTooLong_367(); - break; - case 368: - ChipLogProgress(chipTool, " ***** Test Step 368 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_368(); - break; - case 369: - ChipLogProgress(chipTool, " ***** Test Step 369 : Write attribute NULLABLE_CHAR_STRING - Empty\n"); - err = TestWriteAttributeNullableCharStringEmpty_369(); - break; - case 370: - ChipLogProgress(chipTool, " ***** Test Step 370 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_370(); - break; - case 371: - ChipLogProgress(chipTool, " ***** Test Step 371 : Read attribute NULLABLE_CHAR_STRING not ☉T☉\n"); - err = TestReadAttributeNullableCharStringNott_371(); - break; - case 372: - ChipLogProgress(chipTool, " ***** Test Step 372 : Read attribute from nonexistent endpoint.\n"); - err = TestReadAttributeFromNonexistentEndpoint_372(); - break; - case 373: - ChipLogProgress(chipTool, " ***** Test Step 373 : Read attribute from nonexistent cluster.\n"); - err = TestReadAttributeFromNonexistentCluster_373(); - break; - case 374: - ChipLogProgress(chipTool, " ***** Test Step 374 : Send a command that takes an optional parameter but do not set it.\n"); - err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_374(); - break; - case 375: - ChipLogProgress(chipTool, " ***** Test Step 375 : Send a command that takes an optional parameter but do not set it.\n"); - err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375(); - break; - case 376: - ChipLogProgress(chipTool, " ***** Test Step 376 : Report: Subscribe to list attribute\n"); - err = TestReportSubscribeToListAttribute_376(); - break; - case 377: - ChipLogProgress(chipTool, " ***** Test Step 377 : Subscribe to list attribute\n"); - err = TestSubscribeToListAttribute_377(); - break; - case 378: - ChipLogProgress(chipTool, " ***** Test Step 378 : Write subscribed-to list attribute\n"); - err = TestWriteSubscribedToListAttribute_378(); - break; - case 379: - ChipLogProgress(chipTool, " ***** Test Step 379 : Check for list attribute report\n"); - err = TestCheckForListAttributeReport_379(); - break; - case 380: - ChipLogProgress(chipTool, " ***** Test Step 380 : Read range-restricted unsigned 8-bit integer\n"); - err = TestReadRangeRestrictedUnsigned8BitInteger_380(); - break; - case 381: - ChipLogProgress(chipTool, " ***** Test Step 381 : Write min value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_381(); - break; - case 382: - ChipLogProgress(chipTool, " ***** Test Step 382 : Write just-below-range value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_382(); - break; - case 383: - ChipLogProgress(chipTool, " ***** Test Step 383 : Write just-above-range value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_383(); - break; - case 384: - ChipLogProgress(chipTool, " ***** Test Step 384 : Write max value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_384(); - break; - case 385: - ChipLogProgress(chipTool, " ***** Test Step 385 : Verify range-restricted unsigned 8-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_385(); - break; - case 386: - ChipLogProgress(chipTool, " ***** Test Step 386 : Write min valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_386(); - break; - case 387: - ChipLogProgress(chipTool, " ***** Test Step 387 : Verify range-restricted unsigned 8-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_387(); - break; - case 388: - ChipLogProgress(chipTool, " ***** Test Step 388 : Write max valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_388(); - break; - case 389: - ChipLogProgress(chipTool, " ***** Test Step 389 : Verify range-restricted unsigned 8-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_389(); - break; - case 390: - ChipLogProgress(chipTool, " ***** Test Step 390 : Write middle valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_390(); - break; - case 391: - ChipLogProgress(chipTool, " ***** Test Step 391 : Verify range-restricted unsigned 8-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_391(); - break; - case 392: - ChipLogProgress(chipTool, " ***** Test Step 392 : Read range-restricted unsigned 16-bit integer\n"); - err = TestReadRangeRestrictedUnsigned16BitInteger_392(); - break; - case 393: - ChipLogProgress(chipTool, " ***** Test Step 393 : Write min value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_393(); - break; - case 394: - ChipLogProgress(chipTool, " ***** Test Step 394 : Write just-below-range value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_394(); - break; - case 395: - ChipLogProgress(chipTool, " ***** Test Step 395 : Write just-above-range value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_395(); - break; - case 396: - ChipLogProgress(chipTool, " ***** Test Step 396 : Write max value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_396(); - break; - case 397: - ChipLogProgress(chipTool, " ***** Test Step 397 : Verify range-restricted unsigned 16-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_397(); - break; - case 398: - ChipLogProgress(chipTool, " ***** Test Step 398 : Write min valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_398(); - break; - case 399: - ChipLogProgress(chipTool, " ***** Test Step 399 : Verify range-restricted unsigned 16-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_399(); - break; - case 400: - ChipLogProgress(chipTool, " ***** Test Step 400 : Write max valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_400(); - break; - case 401: - ChipLogProgress(chipTool, " ***** Test Step 401 : Verify range-restricted unsigned 16-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_401(); - break; - case 402: - ChipLogProgress(chipTool, " ***** Test Step 402 : Write middle valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_402(); - break; - case 403: - ChipLogProgress(chipTool, " ***** Test Step 403 : Verify range-restricted unsigned 16-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_403(); - break; - case 404: - ChipLogProgress(chipTool, " ***** Test Step 404 : Read range-restricted signed 8-bit integer\n"); - err = TestReadRangeRestrictedSigned8BitInteger_404(); - break; - case 405: - ChipLogProgress(chipTool, " ***** Test Step 405 : Write min value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedSigned8BitInteger_405(); - break; - case 406: - ChipLogProgress(chipTool, " ***** Test Step 406 : Write just-below-range value to a range-restricted signed 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_406(); - break; - case 407: - ChipLogProgress(chipTool, " ***** Test Step 407 : Write just-above-range value to a range-restricted signed 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_407(); - break; - case 408: - ChipLogProgress(chipTool, " ***** Test Step 408 : Write max value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedSigned8BitInteger_408(); - break; - case 409: - ChipLogProgress(chipTool, " ***** Test Step 409 : Verify range-restricted signed 8-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_409(); - break; - case 410: - ChipLogProgress(chipTool, " ***** Test Step 410 : Write min valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_410(); - break; - case 411: - ChipLogProgress(chipTool, " ***** Test Step 411 : Verify range-restricted signed 8-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_411(); - break; - case 412: - ChipLogProgress(chipTool, " ***** Test Step 412 : Write max valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_412(); - break; - case 413: - ChipLogProgress(chipTool, " ***** Test Step 413 : Verify range-restricted signed 8-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_413(); - break; - case 414: - ChipLogProgress(chipTool, " ***** Test Step 414 : Write middle valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_414(); - break; - case 415: - ChipLogProgress(chipTool, " ***** Test Step 415 : Verify range-restricted signed 8-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_415(); - break; - case 416: - ChipLogProgress(chipTool, " ***** Test Step 416 : Read range-restricted signed 16-bit integer\n"); - err = TestReadRangeRestrictedSigned16BitInteger_416(); - break; - case 417: - ChipLogProgress(chipTool, " ***** Test Step 417 : Write min value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedSigned16BitInteger_417(); - break; - case 418: - ChipLogProgress(chipTool, " ***** Test Step 418 : Write just-below-range value to a range-restricted signed 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_418(); - break; - case 419: - ChipLogProgress(chipTool, " ***** Test Step 419 : Write just-above-range value to a range-restricted signed 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_419(); - break; - case 420: - ChipLogProgress(chipTool, " ***** Test Step 420 : Write max value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedSigned16BitInteger_420(); - break; - case 421: - ChipLogProgress(chipTool, " ***** Test Step 421 : Verify range-restricted signed 16-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_421(); - break; - case 422: - ChipLogProgress(chipTool, " ***** Test Step 422 : Write min valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_422(); - break; - case 423: - ChipLogProgress(chipTool, " ***** Test Step 423 : Verify range-restricted signed 16-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_423(); - break; - case 424: - ChipLogProgress(chipTool, " ***** Test Step 424 : Write max valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_424(); - break; - case 425: - ChipLogProgress(chipTool, " ***** Test Step 425 : Verify range-restricted signed 16-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_425(); - break; - case 426: - ChipLogProgress(chipTool, " ***** Test Step 426 : Write middle valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_426(); - break; - case 427: - ChipLogProgress(chipTool, " ***** Test Step 427 : Verify range-restricted signed 16-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_427(); - break; - case 428: - ChipLogProgress(chipTool, " ***** Test Step 428 : Read nullable range-restricted unsigned 8-bit integer\n"); - err = TestReadNullableRangeRestrictedUnsigned8BitInteger_428(); - break; - case 429: - ChipLogProgress(chipTool, " ***** Test Step 429 : Write min value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_429(); - break; - case 430: - ChipLogProgress(chipTool, " ***** Test Step 430 : Write just-below-range value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_430(); - break; - case 431: - ChipLogProgress(chipTool, " ***** Test Step 431 : Write just-above-range value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431(); - break; - case 432: - ChipLogProgress(chipTool, " ***** Test Step 432 : Write max value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_432(); - break; - case 433: - ChipLogProgress(chipTool, " ***** Test Step 433 : Verify nullable range-restricted unsigned 8-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_433(); - break; - case 434: - ChipLogProgress(chipTool, " ***** Test Step 434 : Write min valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_434(); - break; - case 435: - ChipLogProgress(chipTool, " ***** Test Step 435 : Verify nullable range-restricted unsigned 8-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_435(); - break; - case 436: - ChipLogProgress(chipTool, " ***** Test Step 436 : Write max valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_436(); - break; - case 437: - ChipLogProgress(chipTool, " ***** Test Step 437 : Verify nullable range-restricted unsigned 8-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_437(); - break; - case 438: - ChipLogProgress(chipTool, " ***** Test Step 438 : Write middle valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_438(); - break; - case 439: - ChipLogProgress(chipTool, " ***** Test Step 439 : Verify nullable range-restricted unsigned 8-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_439(); - break; - case 440: - ChipLogProgress(chipTool, " ***** Test Step 440 : Write null value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_440(); - break; - case 441: - ChipLogProgress(chipTool, " ***** Test Step 441 : Verify nullable range-restricted unsigned 8-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_441(); - break; - case 442: - ChipLogProgress(chipTool, " ***** Test Step 442 : Read nullable range-restricted unsigned 16-bit integer\n"); - err = TestReadNullableRangeRestrictedUnsigned16BitInteger_442(); - break; - case 443: - ChipLogProgress(chipTool, " ***** Test Step 443 : Write min value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_443(); - break; - case 444: - ChipLogProgress(chipTool, " ***** Test Step 444 : Write just-below-range value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_444(); - break; - case 445: - ChipLogProgress(chipTool, " ***** Test Step 445 : Write just-above-range value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445(); - break; - case 446: - ChipLogProgress(chipTool, " ***** Test Step 446 : Write max value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_446(); - break; - case 447: - ChipLogProgress(chipTool, " ***** Test Step 447 : Verify nullable range-restricted unsigned 16-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_447(); - break; - case 448: - ChipLogProgress(chipTool, " ***** Test Step 448 : Write min valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_448(); - break; - case 449: - ChipLogProgress(chipTool, " ***** Test Step 449 : Verify nullable range-restricted unsigned 16-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_449(); - break; - case 450: - ChipLogProgress(chipTool, " ***** Test Step 450 : Write max valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_450(); - break; - case 451: - ChipLogProgress(chipTool, " ***** Test Step 451 : Verify nullable range-restricted unsigned 16-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_451(); - break; - case 452: - ChipLogProgress(chipTool, " ***** Test Step 452 : Write middle valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_452(); - break; - case 453: - ChipLogProgress(chipTool, " ***** Test Step 453 : Verify nullable range-restricted unsigned 16-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_453(); - break; - case 454: - ChipLogProgress(chipTool, " ***** Test Step 454 : Write null value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_454(); - break; - case 455: - ChipLogProgress(chipTool, " ***** Test Step 455 : Verify nullable range-restricted unsigned 16-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_455(); - break; - case 456: - ChipLogProgress(chipTool, " ***** Test Step 456 : Read nullable range-restricted signed 8-bit integer\n"); - err = TestReadNullableRangeRestrictedSigned8BitInteger_456(); - break; - case 457: - ChipLogProgress(chipTool, " ***** Test Step 457 : Write min value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_457(); - break; - case 458: - ChipLogProgress(chipTool, " ***** Test Step 458 : Write just-below-range value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_458(); - break; - case 459: - ChipLogProgress(chipTool, " ***** Test Step 459 : Write just-above-range value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_459(); - break; - case 460: - ChipLogProgress(chipTool, " ***** Test Step 460 : Write max value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_460(); - break; - case 461: - ChipLogProgress(chipTool, " ***** Test Step 461 : Verify nullable range-restricted signed 8-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_461(); - break; - case 462: - ChipLogProgress(chipTool, " ***** Test Step 462 : Write min valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_462(); - break; - case 463: - ChipLogProgress(chipTool, " ***** Test Step 463 : Verify nullable range-restricted signed 8-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_463(); - break; - case 464: - ChipLogProgress(chipTool, " ***** Test Step 464 : Write max valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_464(); - break; - case 465: - ChipLogProgress(chipTool, " ***** Test Step 465 : Verify nullable range-restricted signed 8-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_465(); - break; - case 466: - ChipLogProgress(chipTool, " ***** Test Step 466 : Write middle valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_466(); - break; - case 467: - ChipLogProgress(chipTool, " ***** Test Step 467 : Verify nullable range-restricted signed 8-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_467(); - break; - case 468: - ChipLogProgress(chipTool, " ***** Test Step 468 : Write null value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_468(); - break; - case 469: - ChipLogProgress(chipTool, " ***** Test Step 469 : Verify nullable range-restricted signed 8-bit integer value is at null\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_469(); - break; - case 470: - ChipLogProgress(chipTool, " ***** Test Step 470 : Read nullable range-restricted signed 16-bit integer\n"); - err = TestReadNullableRangeRestrictedSigned16BitInteger_470(); - break; - case 471: - ChipLogProgress(chipTool, " ***** Test Step 471 : Write min value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_471(); - break; - case 472: - ChipLogProgress(chipTool, " ***** Test Step 472 : Write just-below-range value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_472(); - break; - case 473: - ChipLogProgress(chipTool, " ***** Test Step 473 : Write just-above-range value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_473(); - break; - case 474: - ChipLogProgress(chipTool, " ***** Test Step 474 : Write max value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_474(); - break; - case 475: - ChipLogProgress(chipTool, " ***** Test Step 475 : Verify nullable range-restricted signed 16-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_475(); - break; - case 476: - ChipLogProgress(chipTool, " ***** Test Step 476 : Write min valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_476(); - break; - case 477: - ChipLogProgress(chipTool, " ***** Test Step 477 : Verify nullable range-restricted signed 16-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_477(); - break; - case 478: - ChipLogProgress(chipTool, " ***** Test Step 478 : Write max valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_478(); - break; - case 479: - ChipLogProgress(chipTool, " ***** Test Step 479 : Verify nullable range-restricted signed 16-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_479(); - break; - case 480: - ChipLogProgress(chipTool, " ***** Test Step 480 : Write middle valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_480(); - break; - case 481: - ChipLogProgress(chipTool, " ***** Test Step 481 : Verify nullable range-restricted signed 16-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_481(); - break; - case 482: - ChipLogProgress(chipTool, " ***** Test Step 482 : Write null value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_482(); - break; - case 483: - ChipLogProgress(chipTool, " ***** Test Step 483 : Verify nullable range-restricted signed 16-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_483(); - break; - case 484: - ChipLogProgress(chipTool, " ***** Test Step 484 : Write attribute that returns general status on write\n"); - err = TestWriteAttributeThatReturnsGeneralStatusOnWrite_484(); - break; - case 485: - ChipLogProgress(chipTool, " ***** Test Step 485 : Write attribute that returns cluster-specific status on write\n"); - err = TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_485(); - break; - case 486: - ChipLogProgress(chipTool, " ***** Test Step 486 : Read attribute that returns general status on read\n"); - err = TestReadAttributeThatReturnsGeneralStatusOnRead_486(); - break; - case 487: - ChipLogProgress(chipTool, " ***** Test Step 487 : read attribute that returns cluster-specific status on read\n"); - err = TestReadAttributeThatReturnsClusterSpecificStatusOnRead_487(); - break; - case 488: - ChipLogProgress(chipTool, " ***** Test Step 488 : read AcceptedCommandList attribute\n"); - err = TestReadAcceptedCommandListAttribute_488(); - break; - case 489: - ChipLogProgress(chipTool, " ***** Test Step 489 : read GeneratedCommandList attribute\n"); - err = TestReadGeneratedCommandListAttribute_489(); - break; - case 490: - ChipLogProgress(chipTool, " ***** Test Step 490 : Write struct-typed attribute\n"); - err = TestWriteStructTypedAttribute_490(); - break; - case 491: - ChipLogProgress(chipTool, " ***** Test Step 491 : Read struct-typed attribute\n"); - err = TestReadStructTypedAttribute_491(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 127: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 128: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 129: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 130: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 131: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 132: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 133: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 134: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 135: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 136: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 137: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 138: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 139: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 140: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 141: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 142: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 143: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 144: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 145: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 146: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 147: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - break; - case 148: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - break; - case 149: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - break; - case 150: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - break; - case 151: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 152: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 153: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 154: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 155: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 156: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 157: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 158: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 159: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 160: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 161: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 162: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 163: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 164: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 165: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 166: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 167: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 168: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 169: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 170: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 171: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 172: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 173: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 174: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 175: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 176: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 177: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 178: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 179: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 180: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 181: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 182: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 183: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 184: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 185: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 186: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 187: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 188: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 189: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 190: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 191: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 192: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 193: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 194: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 195: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 196: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 197: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 198: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 199: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 200: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 201: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 202: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 203: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 204: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 205: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 206: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 207: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 208: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 209: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 210: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 211: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 212: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 213: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 214: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 215: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 216: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 217: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 218: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 219: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 220: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 221: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 222: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 223: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 224: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 225: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 226: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 227: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 228: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 229: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 230: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 231: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 232: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 233: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 234: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 235: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 236: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 237: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 238: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 239: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 240: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 241: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 242: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 243: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 244: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 245: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 246: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 247: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 248: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 249: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 250: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 251: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 252: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 253: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 254: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 255: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 256: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 257: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 258: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 259: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 260: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 261: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 262: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 263: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 264: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 265: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 266: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 267: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 268: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 269: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 270: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 271: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 272: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 273: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 274: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 275: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 276: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 277: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 278: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 279: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 280: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 281: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 282: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 283: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 284: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 285: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 286: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 287: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 288: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 289: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 290: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 291: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 292: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 293: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 294: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 295: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 296: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 297: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 298: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 299: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 300: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 301: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 302: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 303: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 304: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 305: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 306: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 307: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 308: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 309: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 310: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 311: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 312: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 313: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 314: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 315: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 316: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 317: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 318: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 319: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 320: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 321: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 322: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 323: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 324: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 325: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 326: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 327: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 328: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 329: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 330: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 331: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 332: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 333: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 334: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 335: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 336: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 337: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 338: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 339: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 340: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 341: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 342: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 343: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 344: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 345: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 346: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 347: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 348: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 349: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 350: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 351: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 352: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 353: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 354: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 355: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 356: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 357: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 358: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 359: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 360: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 361: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 362: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 363: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 364: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 365: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 366: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 367: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 368: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 369: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 370: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 371: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 372: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - break; - case 373: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - break; - case 374: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 375: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 376: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 377: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 378: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 379: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 380: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 381: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 382: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 383: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 384: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 385: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 386: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 387: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 388: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 389: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 390: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 391: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 392: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 393: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 394: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 395: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 396: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 397: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 398: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 399: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 400: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 401: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 402: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 403: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 404: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 405: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 406: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 407: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 408: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 409: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 410: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 411: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 412: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 413: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 414: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 415: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 416: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 417: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 418: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 419: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 420: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 421: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 422: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 423: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 424: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 425: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 426: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 427: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 428: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 429: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 430: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 431: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 432: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 433: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 434: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 435: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 436: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 437: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 438: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 439: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 440: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 441: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 442: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 443: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 444: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 445: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 446: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 447: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 448: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 449: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 450: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 451: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 452: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 453: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 454: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 455: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 456: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 457: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 458: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 459: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 460: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 461: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 462: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 463: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 464: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 465: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 466: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 467: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 468: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 469: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 470: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 471: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 472: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 473: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 474: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 475: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 476: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 477: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 478: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 479: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 480: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 481: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 482: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 483: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 484: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - break; - case 485: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 486: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - break; - case 487: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 488: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 489: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 490: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 491: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 492; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendTestCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command: Error: %@", err); - } else { - NSLog(@"Send Test Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestNotHandledCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testNotHandledWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Not Handled Command: Error: %@", err); - } else { - NSLog(@"Send Test Not Handled Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestSpecificCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testSpecificWithCompletion: - ^(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Specific Command: Error: %@", err); - } else { - NSLog(@"Send Test Specific Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendFailingTestAddArgumentsCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:250U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:6U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send failing Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send failing Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanDefaultValue_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanTrue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:1]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanTrue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanFalse_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:0]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanFalse_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8MaxValue_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8MaxValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8MinValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8MinValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16MaxValue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16MaxValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16MinValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16MinValue_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32MaxValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32MaxValue_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32MinValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32MinValue_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64MaxValue_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64MaxValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64MinValue_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64MinValue_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uMaxValue_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uMaxValue_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uMinValue_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uMinValue_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uMaxValue_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uMaxValue_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uMinValue_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uMinValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uMaxValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uMaxValue_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uMinValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uMinValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uMaxValue_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uMaxValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uMinValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uMinValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sMaxValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sMaxValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sMinValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sMinValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, -128)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sDefaultValue_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:0]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sMaxValue_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sMaxValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sMinValue_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sMinValue_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, -32768)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sDefaultValue_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:0]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sMaxValue_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:2147483647L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sMaxValue_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sMinValue_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:-2147483648L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sMinValue_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, -2147483648L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sDefaultValue_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:0L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sMaxValue_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:9223372036854775807LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sMaxValue_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sMinValue_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sMinValue_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sDefaultValue_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:0LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleDefaultValue_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleMediumValue_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:0.1f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleMediumValue_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.1f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleLargeValue_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:17000000000.0f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE large Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleLargeValue_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE large Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 17000000000.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleSmallValue_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:1.7e-10f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE small Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleSmallValue_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE small Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 1.7e-10f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleDefaultValue_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:0.0f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleDefaultValue_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleDefaultValue_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleMediumValue_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:0.1234567890123]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleMediumValue_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0.1234567890123)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleLargeValue_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:1.7e+200]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE large Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleLargeValue_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE large Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e+200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleSmallValue_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:1.7e-200]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE small Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleSmallValue_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE small Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e-200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleDefaultValue_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:0]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleDefaultValue_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8MaxValue_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8MaxValue_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8MinValue_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8MinValue_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16MaxValue_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16MaxValue_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16MinValue_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16MinValue_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringDefaultValue_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithEmbeddedNull_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with embedded null: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with embedded null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithEmbeddedNull_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with embedded null: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with embedded null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithHexFormat_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with hex: format: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with hex: format: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithHexFormat_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with hex: format: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with hex: format: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithWeirdChars_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"\015\012\377\042\240" length:5]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with weird chars: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with weird chars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithWeirdChars_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with weird chars: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with weird chars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x0d\x0a\xff\x22\xa0" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetString_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"TestValueLongerThan10" length:21]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetString_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongOctetStringDefaultValue_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongOctetString_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longOctetStringArgument; - longOctetStringArgument = - [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300]; - [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongOctetString_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongOctetString_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longOctetStringArgument; - longOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringDefaultValue_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharString_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"☉T☉"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharString_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueTooLong_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"☉TestValueLongerThan10☉"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING - Value too long: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING - Value too long: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharString_127() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringEmpty_128() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING - Empty: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING - Empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongCharStringDefaultValue_129() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongCharString_130() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longCharStringArgument; - longCharStringArgument = @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉"; - [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongCharString_131() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongCharString_132() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longCharStringArgument; - longCharStringArgument = @""; - [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_133() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); - } else { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_134() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listLongOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[1] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[2] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[3] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[4] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - listLongOctetStringArgument = temp_0; - } - [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); - } else { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_135() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); - } else { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[4], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_136() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listLongOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[1] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[2] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[3] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - listLongOctetStringArgument = temp_0; - } - [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); - } else { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_137() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsMaxValue_138() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsMaxValue_139() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsMinValue_140() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsMinValue_141() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_142() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSMaxValue_143() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSMaxValue_144() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSMinValue_145() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSMinValue_146() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeUnsupported_147() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUnsupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute UNSUPPORTED: Error: %@", err); - } else { - NSLog(@"Read attribute UNSUPPORTED: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteattributeUnsupported_148() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id unsupportedArgument; - unsupportedArgument = - [NSNumber numberWithBool:0]; - [cluster writeAttributeUnsupportedWithValue:unsupportedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Writeattribute UNSUPPORTED: Error: %@", err); - } else { - NSLog(@"Writeattribute UNSUPPORTED: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandToUnsupportedEndpoint_149() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command to unsupported endpoint: Error: %@", err); - } else { - NSLog(@"Send Test Command to unsupported endpoint: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandToUnsupportedCluster_150() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command to unsupported cluster: Error: %@", err); - } else { - NSLog(@"Send Test Command to unsupported cluster: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_151() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorId_152() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:17U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorId_153() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreAttributeVendorId_154() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Restore attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandWithAVendorIdAndEnum_155() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedShort:20003U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:1U]; - [cluster testEnumsRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command with a vendor_id and enum: Error: %@", err); - } else { - NSLog(@"Send a command with a vendor_id and enum: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", actualValue, 20003U)); - } - - { - id actualValue = values.arg2; - VerifyOrReturn(CheckValue("arg2", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandWithAVendorIdAndInvalidEnum_156() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedShort:20003U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:101U]; - [cluster testEnumsRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command with a vendor_id and invalid enum: Error: %@", err); - } else { - NSLog(@"Send a command with a vendor_id and invalid enum: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0]; - - [cluster testStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0]; - - [cluster testStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - [cluster testNestedStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - [cluster testNestedStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = - [NSNumber numberWithDouble:0]; - - temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_1[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_1[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_1[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_1[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_1[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; - } - - [cluster testNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = - [NSNumber numberWithDouble:0]; - - temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_1[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_1[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_1[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_1[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_1[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; - } - - [cluster testNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterSimpleStructEchoRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:17U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.1f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0.1]; - - [cluster simpleStructEchoRequestWithParams:params completion: - ^(MTRUnitTestingClusterSimpleStructResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and see what we get back: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and see what we get back: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 17U)); - VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, false)); - VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); - VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"octet_string" length:12])); - VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"char_string")); - VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 1U)); - VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 0.1f)); - VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 0.1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_164() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - params.arg1 = temp_0; - } - [cluster testListInt8UArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_165() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - temp_0[9] = - [NSNumber numberWithUnsignedChar:0U]; - params.arg1 = temp_0; - } - [cluster testListInt8UArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndGetItReversed_166() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - params.arg1 = temp_0; - } - [cluster testListInt8UReverseRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and get it reversed: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and get it reversed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(9))); - VerifyOrReturn(CheckValue("", actualValue[0], 9U)); - VerifyOrReturn(CheckValue("", actualValue[1], 8U)); - VerifyOrReturn(CheckValue("", actualValue[2], 7U)); - VerifyOrReturn(CheckValue("", actualValue[3], 6U)); - VerifyOrReturn(CheckValue("", actualValue[4], 5U)); - VerifyOrReturn(CheckValue("", actualValue[5], 4U)); - VerifyOrReturn(CheckValue("", actualValue[6], 3U)); - VerifyOrReturn(CheckValue("", actualValue[7], 2U)); - VerifyOrReturn(CheckValue("", actualValue[8], 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_167() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.arg1 = temp_0; - } - [cluster testListInt8UReverseRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Error: %@", err); - } else { - NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_168() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = - [[NSData alloc] initWithBytes:"first_octet_string" length:18]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"first_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = - [NSNumber numberWithDouble:0]; - - temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = - [[NSData alloc] initWithBytes:"second_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"second_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = - [NSNumber numberWithDouble:0]; - - params.arg1 = temp_0; - } - [cluster testListStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_169() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = - [[NSData alloc] initWithBytes:"second_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"second_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = - [NSNumber numberWithDouble:0]; - - temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = - [[NSData alloc] initWithBytes:"first_octet_string" length:18]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"first_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = - [NSNumber numberWithDouble:0]; - - params.arg1 = temp_0; - } - [cluster testListStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_170() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = - [NSNumber numberWithDouble:0]; - - temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_2[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_2[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_2[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_2[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_2[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; - } - - params.arg1 = temp_0; - } - [cluster testListNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_171() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = - [NSNumber numberWithDouble:0]; - - temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_2[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_2[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_2[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_2[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_2[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; - } - - params.arg1 = temp_0; - } - [cluster testListNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_172() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfInt8u_173() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of INT8U: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of INT8U: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - VerifyOrReturn(CheckValue("", actualValue[2], 3U)); - VerifyOrReturn(CheckValue("", actualValue[3], 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfOctetString_174() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"Test0" length:5]; - temp_0[1] = - [[NSData alloc] initWithBytes:"Test1" length:5]; - temp_0[2] = - [[NSData alloc] initWithBytes:"Test2" length:5]; - temp_0[3] = - [[NSData alloc] initWithBytes:"Test3" length:5]; - listOctetStringArgument = temp_0; - } - [cluster writeAttributeListOctetStringWithValue:listOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfOctetString_175() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"Test0" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"Test1" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"Test2" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"Test3" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfListStructOctetString_176() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listStructOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member1 = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member2 = - [[NSData alloc] initWithBytes:"Test0" length:5]; - - temp_0[1] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member1 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member2 = - [[NSData alloc] initWithBytes:"Test1" length:5]; - - temp_0[2] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member1 = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member2 = - [[NSData alloc] initWithBytes:"Test2" length:5]; - - temp_0[3] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member1 = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member2 = - [[NSData alloc] initWithBytes:"Test3" length:5]; - - listStructOctetStringArgument = temp_0; - } - [cluster writeAttributeListStructOctetStringWithValue:listStructOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfListStructOctetString_177() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListStructOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_struct_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member1, 0ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member2, [[NSData alloc] initWithBytes:"Test0" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member1, 1ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member2, [[NSData alloc] initWithBytes:"Test1" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member1, 2ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member2, [[NSData alloc] initWithBytes:"Test2" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member1, 3ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member2, [[NSData alloc] initWithBytes:"Test3" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithOptionalArgSet_178() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:5U]; - [cluster testNullableOptionalRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command with optional arg set.: Error: %@", err); - } else { - NSLog(@"Send Test Command with optional arg set.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.wasPresent; - VerifyOrReturn(CheckValue("wasPresent", actualValue, true)); - } - - { - id actualValue = values.wasNull; - VerifyOrReturn(CheckValue("wasNull", actualValue, false)); - } - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, 5U)); - } - - { - id actualValue = values.originalValue; - VerifyOrReturn(CheckValueNonNull("originalValue", actualValue)); - VerifyOrReturn(CheckValue("originalValue", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithoutItsOptionalArg_179() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; - [cluster testNullableOptionalRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command without its optional arg.: Error: %@", err); - } else { - NSLog(@"Send Test Command without its optional arg.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.wasPresent; - VerifyOrReturn(CheckValue("wasPresent", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionals_180() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read list of structs containing nullables and optionals: Error: %@", err); - } else { - NSLog(@"Read list of structs containing nullables and optionals: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); - VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); - VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); - VerifyOrReturn(CheckValueNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteListOfStructsContainingNullablesAndOptionals_181() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listNullablesAndOptionalsStructArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNullablesAndOptionalsStruct alloc] init]; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableInt = nil; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableString = nil; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableStruct = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_3[1] = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableList = temp_3; - } - - listNullablesAndOptionalsStructArgument = temp_0; - } - [cluster writeAttributeListNullablesAndOptionalsStructWithValue:listNullablesAndOptionalsStructArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write list of structs containing nullables and optionals: Error: %@", err); - } else { - NSLog(@"Write list of structs containing nullables and optionals: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_182() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read list of structs containing nullables and optionals after writing: Error: %@", err); - } else { - NSLog(@"Read list of structs containing nullables and optionals after writing: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); - VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); - VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); - VerifyOrReturn(CheckValueNonNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); - VerifyOrReturn(CheckValue("NullableList", [((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList count], static_cast(2))); - VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[0], 1U)); - VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanNull_183() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = nil; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BOOLEAN null: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BOOLEAN null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable booValueNull; - - CHIP_ERROR TestReadAttributeNullableBooleanNull_184() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN null: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } - { - booValueNull = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanTrue_185() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = - [NSNumber numberWithBool:true]; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanTrue_186() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanNotNull_187() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableBoolean", value, booValueNull)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8MaxValue_188() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8MaxValue_189() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8InvalidValue_190() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable nullableValue254; - - CHIP_ERROR TestReadAttributeNullableBitmap8UnchangedValue_191() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); - } - { - nullableValue254 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8NullValue_192() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = nil; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8NullValue_193() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap8", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8Not254Value_194() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableBitmap8", value, nullableValue254)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16MaxValue_195() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16MaxValue_196() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16InvalidValue_197() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16UnchangedValue_198() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16NullValue_199() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = nil; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16NullValue_200() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap16", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32MaxValue_201() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967294UL]; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32MaxValue_202() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32InvalidValue_203() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32UnchangedValue_204() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32NullValue_205() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = nil; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32NullValue_206() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap32", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64MaxValue_207() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64MaxValue_208() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64InvalidValue_209() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64UnchangedValue_210() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64NullValue_211() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = nil; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64NullValue_212() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap64", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uMinValue_213() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uMinValue_214() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uMaxValue_215() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uMaxValue_216() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uInvalidValue_217() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValue_218() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValueWithConstraint_219() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("nullableInt8u", value)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uNullValue_220() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = nil; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValue_221() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int8u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValueRange_222() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValueNot_223() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uValue_224() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:128U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uValueInRange_225() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNotValueOk_226() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 129U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uMinValue_227() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uMinValue_228() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uMaxValue_229() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uMaxValue_230() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uInvalidValue_231() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uUnchangedValue_232() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uNullValue_233() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = nil; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValue_234() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int16u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValueRange_235() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValueNot_236() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 65534U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uValue_237() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:32000U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uValueInRange_238() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNotValueOk_239() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 32001U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uMinValue_240() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uMinValue_241() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uMaxValue_242() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:4294967294UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uMaxValue_243() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uInvalidValue_244() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uUnchangedValue_245() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uNullValue_246() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = nil; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValue_247() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int32u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValueRange_248() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValueNot_249() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 4294967294UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uValue_250() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:2147483647UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uValueInRange_251() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNotValueOk_252() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 2147483648UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uMinValue_253() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uMinValue_254() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uMaxValue_255() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uMaxValue_256() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uInvalidValue_257() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uUnchangedValue_258() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uNullValue_259() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = nil; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValue_260() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int64u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValueRange_261() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValueNot_262() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18446744073709551614ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uValue_263() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18000000000000000000ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uValueInRange_264() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNotValueOk_265() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18000000000000000001ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sMinValue_266() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sMinValue_267() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sInvalidValue_268() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sUnchangedValue_269() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sNullValue_270() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = nil; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValue_271() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int8s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValueRange_272() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValueNot_273() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -127)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sValue_274() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sValueInRange_275() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNotValueOk_276() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -126)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sMinValue_277() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sMinValue_278() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sInvalidValue_279() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sUnchangedValue_280() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sNullValue_281() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = nil; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValue_282() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int16s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValueRange_283() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValueNot_284() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32767)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sValue_285() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sValueInRange_286() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNotValueOk_287() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32766)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sMinValue_288() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483647L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sMinValue_289() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sInvalidValue_290() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483648L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sUnchangedValue_291() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sNullValue_292() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = nil; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValue_293() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int32s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValueRange_294() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValueNot_295() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483647L)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sValue_296() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483647L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sValueInRange_297() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNotValueOk_298() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483646L)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sMinValue_299() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sMinValue_300() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sInvalidValue_301() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL - 1LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sUnchangedValue_302() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sNullValue_303() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = nil; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValue_304() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int64s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValueRange_305() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValueNot_306() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775807LL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sValue_307() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sValueInRange_308() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNotValueOk_309() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775806LL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleMediumValue_310() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:0.1f]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleMediumValue_311() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.1f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleLargestValue_312() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:INFINITY]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleLargestValue_313() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleSmallestValue_314() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:-INFINITY]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleSmallestValue_315() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, -INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleNullValue_316() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = nil; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleNullValue_317() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_float_single", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingle0Value_318() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:0.0f]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingle0Value_319() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleMediumValue_320() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:0.1234567890123]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleMediumValue_321() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0.1234567890123)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleLargestValue_322() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:INFINITY]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleLargestValue_323() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleSmallestValue_324() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:-INFINITY]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleSmallestValue_325() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, -INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleNullValue_326() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = nil; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleNullValue_327() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_float_double", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDouble0Value_328() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:0]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDouble0Value_329() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8MinValue_330() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8MinValue_331() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8MaxValue_332() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8MaxValue_333() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8InvalidValue_334() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8UnchangedValue_335() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8NullValue_336() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = nil; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8NullValue_337() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum8", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16MinValue_338() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16MinValue_339() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16MaxValue_340() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16MaxValue_341() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16InvalidValue_342() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16UnchangedValue_343() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16NullValue_344() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = nil; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16NullValue_345() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum16", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumMinValue_346() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumMinValue_347() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumMaxValue_348() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumMaxValue_349() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumInvalidValue_350() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable nullableEnumAttr3; - - CHIP_ERROR TestReadAttributeNullableSimpleEnumUnchangedValue_351() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); - } - { - nullableEnumAttr3 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumNullValue_352() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = nil; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumNullValue_353() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum_attr", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumNot3Value_354() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableEnumAttr", value, nullableEnumAttr3)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_355() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_356() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nullable nullableOctetStrTestValue; - - CHIP_ERROR TestReadAttributeNullableOctetString_357() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - { - nullableOctetStrTestValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_358() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = nil; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_359() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_octet_string", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_360() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_361() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringNotTestValue_362() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableOctetString", value, nullableOctetStrTestValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringDefaultValue_363() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharString_364() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @"☉T☉"; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nullable nullableCharStringSave; - - CHIP_ERROR TestReadAttributeNullableCharString_365() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"☉T☉")); - } - { - nullableCharStringSave = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_366() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (nullableCharStringSave == nil) { - VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, nullableCharStringSave)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValueTooLong_367() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = nil; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_368() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringEmpty_369() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @""; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_370() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringNott_371() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableCharString", value, nullableCharStringSave)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeFromNonexistentEndpoint_372() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute from nonexistent endpoint.: Error: %@", err); - } else { - NSLog(@"Read attribute from nonexistent endpoint.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeFromNonexistentCluster_373() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute from nonexistent cluster.: Error: %@", err); - } else { - NSLog(@"Read attribute from nonexistent cluster.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_374() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; - [cluster testSimpleOptionalArgumentRequestWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); - } else { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithBool:1]; - [cluster testSimpleOptionalArgumentRequestWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); - } else { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestCluster_376_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestCluster_list_int8u_Reported - = nil; - - CHIP_ERROR TestReportSubscribeToListAttribute_376() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestCluster_list_int8u_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe to list attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - VerifyOrReturn(CheckValue("", actualValue[2], 3U)); - VerifyOrReturn(CheckValue("", actualValue[3], 4U)); - } - - testSendClusterTestCluster_376_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeToListAttribute_377() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeListInt8uWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestCluster_376_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe to list attribute: Error: %@", err); - } else { - NSLog(@"Subscribe to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestCluster_list_int8u_Reported - != nil) { - ResponseHandler callback = test_TestCluster_list_int8u_Reported; - test_TestCluster_list_int8u_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSubscribedToListAttribute_378() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:8U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write subscribed-to list attribute: Error: %@", err); - } else { - NSLog(@"Write subscribed-to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForListAttributeReport_379() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestCluster_list_int8u_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for list attribute report: Error: %@", err); - } else { - NSLog(@"Check for list attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 5U)); - VerifyOrReturn(CheckValue("", actualValue[1], 6U)); - VerifyOrReturn(CheckValue("", actualValue[2], 7U)); - VerifyOrReturn(CheckValue("", actualValue[3], 8U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedUnsigned8BitInteger_380() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_381() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_382() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:19U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_383() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:101U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_384() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_385() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_386() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:20U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_387() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_388() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:100U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_389() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_390() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_391() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedUnsigned16BitInteger_392() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_393() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_394() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:99U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_395() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1001U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_396() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_397() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_398() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:100U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_399() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_400() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1000U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_401() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 1000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_402() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:500U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_403() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedSigned8BitInteger_404() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned8BitInteger_405() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_406() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-41]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_407() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:51]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned8BitInteger_408() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_409() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_410() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-40]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_411() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -40)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_412() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:50]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_413() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 50)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_414() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:6]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_415() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 6)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedSigned16BitInteger_416() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned16BitInteger_417() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_418() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-151]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_419() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:201]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned16BitInteger_420() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_421() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_422() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-150]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_423() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -150)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_424() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:200]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_425() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_426() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:7]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_427() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 7)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedUnsigned8BitInteger_428() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_429() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_430() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:19U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:101U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_432() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_433() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_434() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:20U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_435() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_436() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:100U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_437() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_438() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_439() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_440() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_441() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedUnsigned16BitInteger_442() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_443() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_444() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:99U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1001U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_446() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_447() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_448() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:100U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_449() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_450() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1000U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_451() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 1000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_452() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:500U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_453() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_454() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_455() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedSigned8BitInteger_456() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_457() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_458() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-41]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_459() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:51]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_460() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_461() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_462() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-40]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_463() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -40)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_464() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:50]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_465() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 50)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_466() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:6]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_467() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 6)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_468() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_469() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedSigned16BitInteger_470() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_471() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_472() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-151]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_473() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:201]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_474() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_475() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_476() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-150]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_477() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -150)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_478() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:200]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_479() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_480() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:7]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_481() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 7)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_482() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_483() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeThatReturnsGeneralStatusOnWrite_484() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id generalErrorBooleanArgument; - generalErrorBooleanArgument = - [NSNumber numberWithBool:false]; - [cluster writeAttributeGeneralErrorBooleanWithValue:generalErrorBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute that returns general status on write: Error: %@", err); - } else { - NSLog(@"Write attribute that returns general status on write: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_485() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id clusterErrorBooleanArgument; - clusterErrorBooleanArgument = - [NSNumber numberWithBool:false]; - [cluster writeAttributeClusterErrorBooleanWithValue:clusterErrorBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute that returns cluster-specific status on write: Error: %@", err); - } else { - NSLog(@"Write attribute that returns cluster-specific status on write: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeThatReturnsGeneralStatusOnRead_486() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneralErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute that returns general status on read: Error: %@", err); - } else { - NSLog(@"Read attribute that returns general status on read: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeThatReturnsClusterSpecificStatusOnRead_487() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read attribute that returns cluster-specific status on read: Error: %@", err); - } else { - NSLog(@"read attribute that returns cluster-specific status on read: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAcceptedCommandListAttribute_488() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"read AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(20))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 7UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 13UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 14UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 15UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 17UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 18UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 19UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 20UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 21UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 22UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 23UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadGeneratedCommandListAttribute_489() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"read GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(10))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 5UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 6UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteStructTypedAttribute_490() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id structAttrArgument; - structAttrArgument = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).a = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).d = - [[NSData alloc] initWithBytes:"abc" length:3]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).e = @""; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).f = - [NSNumber numberWithUnsignedChar:17U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).g = - [NSNumber numberWithFloat:1.5f]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).h = - [NSNumber numberWithDouble:3.14159265358979]; - - [cluster writeAttributeStructAttrWithValue:structAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write struct-typed attribute: Error: %@", err); - } else { - NSLog(@"Write struct-typed attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStructTypedAttribute_491() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStructAttrWithCompletion:^(MTRUnitTestingClusterSimpleStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read struct-typed attribute: Error: %@", err); - } else { - NSLog(@"Read struct-typed attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 5U)); - VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, true)); - VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); - VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"abc" length:3])); - VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"")); - VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 17U)); - VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 1.5f)); - VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 3.14159265358979)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestConstraints() - : TestCommandBridge("TestConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write attribute LIST With List of INT8U\n"); - err = TestWriteAttributeListWithListOfInt8u_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute LIST With Partial List of INT8U that should be in it\n"); - err = TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute LIST With Partial List of INT8U that should not be included\n"); - err = TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write attribute LIST Back to Default Value\n"); - err = TestWriteAttributeListBackToDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Write attribute BITMAP32 with MaskVal1 and MaskVal3\n"); - err = TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Write attribute BITMAP32 with MaskVal1\n"); - err = TestWriteAttributeBitmap32WithMaskVal1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write attribute BITMAP32 Back to Default Value\n"); - err = TestWriteAttributeBitmap32BackToDefaultValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute INT32U Value\n"); - err = TestWriteAttributeInt32uValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute INT32U Value MinValue Constraints\n"); - err = TestReadAttributeInt32uValueMinValueConstraints_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute INT32U Value MaxValue Constraints\n"); - err = TestReadAttributeInt32uValueMaxValueConstraints_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute INT32U Value NotValue Constraints\n"); - err = TestReadAttributeInt32uValueNotValueConstraints_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Write attribute INT32U Value Back to Default Value\n"); - err = TestWriteAttributeInt32uValueBackToDefaultValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute CHAR_STRING Value MinLength Constraints\n"); - err = TestReadAttributeCharStringValueMinLengthConstraints_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute CHAR_STRING Value MaxLength Constraints\n"); - err = TestReadAttributeCharStringValueMaxLengthConstraints_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read attribute CHAR_STRING Value StartsWith Constraints\n"); - err = TestReadAttributeCharStringValueStartsWithConstraints_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute CHAR_STRING Value EndsWith Constraints\n"); - err = TestReadAttributeCharStringValueEndsWithConstraints_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute CHAR_STRING Value with only digits\n"); - err = TestWriteAttributeCharStringValueWithOnlyDigits_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute CHAR_STRING Value with only non-letters\n"); - err = TestWriteAttributeCharStringValueWithOnlyNonLetters_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute CHAR_STRING Value with uppercase letters and symbols\n"); - err = TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Write attribute CHAR_STRING Value with lowercase letters and symbols\n"); - err = TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Write attribute CHAR_STRING Value which is empty\n"); - err = TestWriteAttributeCharStringValueWhichIsEmpty_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute CHAR_STRING Value isHexString Constraints\n"); - err = TestReadAttributeCharStringValueIsHexStringConstraints_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute CHAR_STRING Value isHexString Constraints\n"); - err = TestReadAttributeCharStringValueIsHexStringConstraints_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute CHAR_STRING Value Back to Default Value\n"); - err = TestWriteAttributeCharStringValueBackToDefaultValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute NULLABLE_CHAR_STRING Value\n"); - err = TestWriteAttributeNullableCharStringValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints\n"); - err = TestReadAttributeNullableCharStringValueMinLengthConstraints_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints\n"); - err = TestReadAttributeNullableCharStringValueMaxLengthConstraints_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Write attribute NULLABLE_CHAR_STRING Value Back to Default Value\n"); - err = TestWriteAttributeNullableCharStringValueBackToDefaultValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute NULLABLE_INT8U Default Value\n"); - err = TestReadAttributeNullableInt8uDefaultValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute NULLABLE_INT8U with a value\n"); - err = TestWriteAttributeNullableInt8uWithAValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute NULLABLE_INT8U with a value\n"); - err = TestReadAttributeNullableInt8uWithAValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute NULLABLE_INT8U without a value\n"); - err = TestWriteAttributeNullableInt8uWithoutAValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute NULLABLE_INT8U with a value\n"); - err = TestReadAttributeNullableInt8uWithAValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute NULLABLE_INT8U back to Default Value\n"); - err = TestWriteAttributeNullableInt8uBackToDefaultValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); - err = TestReadAttributeNullableOctetStringDefaultValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute NULLABLE_OCTET_STRING back to Default Value\n"); - err = TestWriteAttributeNullableOctetStringBackToDefaultValue_60(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 61; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteAttributeListWithListOfInt8u_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of INT8U: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of INT8U: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 2U)); - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 3U)); - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 0U)); - VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListBackToDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute LIST Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:5UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 with MaskVal1: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 with MaskVal1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32BackToDefaultValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:5UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueMinValueConstraints_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value MinValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value MinValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("int32u", [value unsignedIntValue], 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueMaxValueConstraints_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value MaxValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value MaxValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("int32u", [value unsignedIntValue], 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueNotValueConstraints_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value NotValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value NotValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32u", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uValueBackToDefaultValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"** Test **"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueMinLengthConstraints_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("charString", value, 5)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueMaxLengthConstraints_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxLength("charString", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueStartsWithConstraints_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintStartsWith("charString", value, "**")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueEndsWithConstraints_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintEndsWith("charString", value, "**")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"lowercase"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"UPPERCASE"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"lowUPPER"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyDigits_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"1234567890"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with only digits: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with only digits: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyNonLetters_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"12.4,76:"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABC;.* "; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"abc;.* "; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWhichIsEmpty_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value which is empty: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value which is empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABCDEF012V"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsHexString("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABCDEF0123"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsHexString("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueBackToDefaultValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = nil; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringValueMinLengthConstraints_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinLength("nullableCharString", value, 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringValueMaxLengthConstraints_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMaxLength("nullableCharString", value, 20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValueBackToDefaultValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @""; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uDefaultValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uWithAValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uWithoutAValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = nil; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U without a value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U without a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uBackToDefaultValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = nil; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetStringBackToDefaultValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDelayCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDelayCommands() - : TestCommandBridge("TestDelayCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDelayCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDelayCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDelayCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Wait 100ms\n"); - err = TestWait100ms_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWait100ms_1() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } -}; - -class TestLogCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestLogCommands() - : TestCommandBridge("TestLogCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestLogCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestLogCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestLogCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Log a simple message\n"); - err = TestLogASimpleMessage_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Do a simple user prompt message\n"); - err = TestDoASimpleUserPromptMessage_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestLogASimpleMessage_1() - { - - chip::app::Clusters::LogCommands::Commands::Log::Type value; - value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); - return Log("alpha", value); - } - - CHIP_ERROR TestDoASimpleUserPromptMessage_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); - return UserPrompt("alpha", value); - } -}; - -class TestSaveAs : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSaveAs() - : TestCommandBridge("TestSaveAs") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSaveAs() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSaveAs\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSaveAs\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute BOOLEAN Default Value\n"); - err = TestReadAttributeBooleanDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write attribute BOOLEAN Not Default Value\n"); - err = TestWriteAttributeBooleanNotDefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Not Default Value\n"); - err = TestReadAttributeBooleanNotDefaultValue_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN DefaultValue\n"); - err = TestWriteAttributeBooleanDefaultValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN False\n"); - err = TestReadAttributeBooleanFalse_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Write attribute BITMAP8 Not Default Value\n"); - err = TestWriteAttributeBitmap8NotDefaultValue_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Not Default Value\n"); - err = TestReadAttributeBitmap8NotDefaultValue_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Default Value\n"); - err = TestWriteAttributeBitmap8DefaultValue_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write attribute BITMAP16 Not Default Value\n"); - err = TestWriteAttributeBitmap16NotDefaultValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Not Default Value\n"); - err = TestReadAttributeBitmap16NotDefaultValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Default Value\n"); - err = TestWriteAttributeBitmap16DefaultValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Write attribute BITMAP32 Not Default Value\n"); - err = TestWriteAttributeBitmap32NotDefaultValue_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Not Default Value\n"); - err = TestReadAttributeBitmap32NotDefaultValue_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Default Value\n"); - err = TestWriteAttributeBitmap32DefaultValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Write attribute BITMAP64 Not Default Value\n"); - err = TestWriteAttributeBitmap64NotDefaultValue_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Default Value\n"); - err = TestWriteAttributeBitmap64DefaultValue_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute INT8U Not Default Value\n"); - err = TestWriteAttributeInt8uNotDefaultValue_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Not Default Value\n"); - err = TestReadAttributeInt8uNotDefaultValue_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Default Value\n"); - err = TestWriteAttributeInt8uDefaultValue_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Write attribute INT16U Not Default Value\n"); - err = TestWriteAttributeInt16uNotDefaultValue_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Not Default Value\n"); - err = TestReadAttributeInt16uNotDefaultValue_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Default Value\n"); - err = TestWriteAttributeInt16uDefaultValue_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute INT32U Not Default Value\n"); - err = TestWriteAttributeInt32uNotDefaultValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Not Default Value\n"); - err = TestReadAttributeInt32uNotDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Default Value\n"); - err = TestWriteAttributeInt32uDefaultValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute INT64U Not Default Value\n"); - err = TestWriteAttributeInt64uNotDefaultValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Not Default Value\n"); - err = TestReadAttributeInt64uNotDefaultValue_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Default Value\n"); - err = TestWriteAttributeInt64uDefaultValue_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute INT8S Not Default Value\n"); - err = TestWriteAttributeInt8sNotDefaultValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Not Default Value\n"); - err = TestReadAttributeInt8sNotDefaultValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Default Value\n"); - err = TestWriteAttributeInt8sDefaultValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Write attribute INT16S Not Default Value\n"); - err = TestWriteAttributeInt16sNotDefaultValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Read attribute INT16S Not Default Value\n"); - err = TestReadAttributeInt16sNotDefaultValue_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Write attribute INT16S Default Value\n"); - err = TestWriteAttributeInt16sDefaultValue_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute INT32S Not Default Value\n"); - err = TestWriteAttributeInt32sNotDefaultValue_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Read attribute INT32S Not Default Value\n"); - err = TestReadAttributeInt32sNotDefaultValue_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Write attribute INT32S Default Value\n"); - err = TestWriteAttributeInt32sDefaultValue_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Write attribute INTS Not Default Value\n"); - err = TestWriteAttributeIntsNotDefaultValue_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Read attribute INT64S Not Default Value\n"); - err = TestReadAttributeInt64sNotDefaultValue_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Write attribute INT64S Default Value\n"); - err = TestWriteAttributeInt64sDefaultValue_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute ENUM8 Not Default Value\n"); - err = TestWriteAttributeEnum8NotDefaultValue_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute ENUM8 Not Default Value\n"); - err = TestReadAttributeEnum8NotDefaultValue_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Write attribute ENUM8 Default Value\n"); - err = TestWriteAttributeEnum8DefaultValue_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute ENUM16 Not Default Value\n"); - err = TestWriteAttributeEnum16NotDefaultValue_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute ENUM16 Not Default Value\n"); - err = TestReadAttributeEnum16NotDefaultValue_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute ENUM16 Default Value\n"); - err = TestWriteAttributeEnum16DefaultValue_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute EPOCH_US Not Default Value\n"); - err = TestWriteAttributeEpochUsNotDefaultValue_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute EPOCH_US Not Default Value\n"); - err = TestReadAttributeEpochUsNotDefaultValue_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute EPOCH_US Default Value\n"); - err = TestWriteAttributeEpochUsDefaultValue_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Write attribute EPOCH_S Not Default Value\n"); - err = TestWriteAttributeEpochSNotDefaultValue_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Read attribute EPOCH_S Not Default Value\n"); - err = TestReadAttributeEpochSNotDefaultValue_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Write attribute EPOCH_S Default Value\n"); - err = TestWriteAttributeEpochSDefaultValue_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Write attribute vendor_id Not Default Value\n"); - err = TestWriteAttributeVendorIdNotDefaultValue_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Read attribute vendor_id Not Default Value\n"); - err = TestReadAttributeVendorIdNotDefaultValue_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Write attribute vendor_id Default Value\n"); - err = TestWriteAttributeVendorIdDefaultValue_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute char_string Default Value\n"); - err = TestReadAttributeCharStringDefaultValue_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Read attribute char_string Default Value and compare to saved value\n"); - err = TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Write attribute char_string Not Default Value\n"); - err = TestWriteAttributeCharStringNotDefaultValue_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute char_string Not Default Value\n"); - err = TestReadAttributeCharStringNotDefaultValue_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Read attribute char_string Not Default Value and compare to saved value\n"); - err = TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Write attribute char_string Not Default Value from saved value\n"); - err = TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Read attribute char_string Not Default Value and compare to expected value\n"); - err = TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Write attribute char_string Default Value\n"); - err = TestWriteAttributeCharStringDefaultValue_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute octet_string Default Value\n"); - err = TestReadAttributeOctetStringDefaultValue_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Read attribute octet_string Default Value and compare to saved value\n"); - err = TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Write attribute octet_string Not Default Value\n"); - err = TestWriteAttributeOctetStringNotDefaultValue_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Read attribute octet_string Not Default Value\n"); - err = TestReadAttributeOctetStringNotDefaultValue_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute octet_string Not Default Value and compare to saved value\n"); - err = TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Write attribute octet_string Not Default Value from saved value\n"); - err = TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Read attribute octet_string Not Default Value and compare to expected value\n"); - err = TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Write attribute octet_string Default Value\n"); - err = TestWriteAttributeOctetStringDefaultValue_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Read attribute nullable_boolean Default Value\n"); - err = TestReadAttributeNullableBooleanDefaultValue_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Write attribute nullable_boolean to null\n"); - err = TestWriteAttributeNullableBooleanToNull_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Read attribute nullable_boolean null Value\n"); - err = TestReadAttributeNullableBooleanNullValue_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute nullable_boolean null Value again and compare it to the previously saved value\n"); - err = TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute nullable_boolean Default Value\n"); - err = TestWriteAttributeNullableBooleanDefaultValue_114(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 115; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull TestAddArgumentDefaultValue; - - CHIP_ERROR TestSendTestAddArgumentsCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - { - TestAddArgumentDefaultValue = values.returnValue; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, TestAddArgumentDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [TestAddArgumentDefaultValue copy]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("returnValue", values.returnValue, TestAddArgumentDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBooleanDefaultValue; - - CHIP_ERROR TestReadAttributeBooleanDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - { - readAttributeBooleanDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanNotDefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:1]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanNotDefaultValue_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("boolean", value, readAttributeBooleanDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanDefaultValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [readAttributeBooleanDefaultValue copy]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN DefaultValue: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN DefaultValue: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanFalse_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, readAttributeBooleanDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap8DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - { - readAttributeBitmap8DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8NotDefaultValue_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8NotDefaultValue_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap8", value, readAttributeBitmap8DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8DefaultValue_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [readAttributeBitmap8DefaultValue copy]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, readAttributeBitmap8DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap16DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - { - readAttributeBitmap16DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16NotDefaultValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16NotDefaultValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap16", value, readAttributeBitmap16DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16DefaultValue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [readAttributeBitmap16DefaultValue copy]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, readAttributeBitmap16DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap32DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - { - readAttributeBitmap32DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32NotDefaultValue_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32NotDefaultValue_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap32", value, readAttributeBitmap32DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32DefaultValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [readAttributeBitmap32DefaultValue copy]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, readAttributeBitmap32DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap64DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - { - readAttributeBitmap64DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64NotDefaultValue_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap64", value, readAttributeBitmap64DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64DefaultValue_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [readAttributeBitmap64DefaultValue copy]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, readAttributeBitmap64DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt8uDefaultValue; - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - { - readAttributeInt8uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uNotDefaultValue_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uNotDefaultValue_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int8u", value, readAttributeInt8uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uDefaultValue_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [readAttributeInt8uDefaultValue copy]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, readAttributeInt8uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt16uDefaultValue; - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - { - readAttributeInt16uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uNotDefaultValue_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uNotDefaultValue_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int16u", value, readAttributeInt16uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uDefaultValue_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [readAttributeInt16uDefaultValue copy]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, readAttributeInt16uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt32uDefaultValue; - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - { - readAttributeInt32uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uNotDefaultValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uNotDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32u", value, readAttributeInt32uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uDefaultValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [readAttributeInt32uDefaultValue copy]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, readAttributeInt32uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt64uDefaultValue; - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - { - readAttributeInt64uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uNotDefaultValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uNotDefaultValue_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int64u", value, readAttributeInt64uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uDefaultValue_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [readAttributeInt64uDefaultValue copy]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, readAttributeInt64uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt8sDefaultValue; - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - { - readAttributeInt8sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sNotDefaultValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:1]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sNotDefaultValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int8s", value, readAttributeInt8sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sDefaultValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [readAttributeInt8sDefaultValue copy]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, readAttributeInt8sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt16sDefaultValue; - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - { - readAttributeInt16sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sNotDefaultValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:1]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sNotDefaultValue_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int16s", value, readAttributeInt16sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sDefaultValue_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [readAttributeInt16sDefaultValue copy]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, readAttributeInt16sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt32sDefaultValue; - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - { - readAttributeInt32sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sNotDefaultValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:1L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sNotDefaultValue_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32s", value, readAttributeInt32sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sDefaultValue_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [readAttributeInt32sDefaultValue copy]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, readAttributeInt32sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt64sDefaultValue; - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - { - readAttributeInt64sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeIntsNotDefaultValue_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:1LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INTS Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INTS Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sNotDefaultValue_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int64s", value, readAttributeInt64sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sDefaultValue_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [readAttributeInt64sDefaultValue copy]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, readAttributeInt64sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEnum8DefaultValue; - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - { - readAttributeEnum8DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8NotDefaultValue_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8NotDefaultValue_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("enum8", value, readAttributeEnum8DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8DefaultValue_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [readAttributeEnum8DefaultValue copy]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, readAttributeEnum8DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEnum16DefaultValue; - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - { - readAttributeEnum16DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16NotDefaultValue_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16NotDefaultValue_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("enum16", value, readAttributeEnum16DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16DefaultValue_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [readAttributeEnum16DefaultValue copy]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, readAttributeEnum16DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEpochUSDefaultValue; - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - { - readAttributeEpochUSDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsNotDefaultValue_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsNotDefaultValue_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("epochUs", value, readAttributeEpochUSDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsDefaultValue_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [readAttributeEpochUSDefaultValue copy]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, readAttributeEpochUSDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEpochSDefaultValue; - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - { - readAttributeEpochSDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSNotDefaultValue_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSNotDefaultValue_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("epochS", value, readAttributeEpochSDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSDefaultValue_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [readAttributeEpochSDefaultValue copy]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, readAttributeEpochSDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeVendorIdDefaultValue; - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); - } - { - readAttributeVendorIdDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorIdNotDefaultValue_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdNotDefaultValue_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("vendorId", value, readAttributeVendorIdDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorIdDefaultValue_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [readAttributeVendorIdDefaultValue copy]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, readAttributeVendorIdDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull readAttributeCharStringDefaultValue; - - CHIP_ERROR TestReadAttributeCharStringDefaultValue_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); - } - { - readAttributeCharStringDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringNotDefaultValue_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"NotDefault"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull readAttributeCharStringNotDefaultValue; - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValue_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); - } - - VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); - { - readAttributeCharStringNotDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringNotDefaultValue)); - } - - VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = - [readAttributeCharStringNotDefaultValue copy]; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Not Default Value from saved value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Not Default Value from saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringDefaultValue_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = - [readAttributeCharStringDefaultValue copy]; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nonnull readAttributeOctetStringDefaultValue; - - CHIP_ERROR TestReadAttributeOctetStringDefaultValue_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - { - readAttributeOctetStringDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValue_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"NotDefault" length:10]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nonnull readAttributeOctetStringNotDefaultValue; - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValue_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); - } - - VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); - { - readAttributeOctetStringNotDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringNotDefaultValue)); - } - - VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [readAttributeOctetStringNotDefaultValue copy]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Not Default Value from saved value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Not Default Value from saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringDefaultValue_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [readAttributeOctetStringDefaultValue copy]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable readAttributeNullableBooleanDefaultValue; - - CHIP_ERROR TestReadAttributeNullableBooleanDefaultValue_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, false)); - } - { - readAttributeNullableBooleanDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanToNull_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = nil; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute nullable_boolean to null: Error: %@", err); - } else { - NSLog(@"Write attribute nullable_boolean to null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable readAttributeNullableBooleanNullValue; - - CHIP_ERROR TestReadAttributeNullableBooleanNullValue_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean null Value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } - { - readAttributeNullableBooleanNullValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (readAttributeNullableBooleanNullValue == nil) { - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, readAttributeNullableBooleanNullValue)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanDefaultValue_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = - [readAttributeNullableBooleanDefaultValue copy]; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute nullable_boolean Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute nullable_boolean Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestConfigVariables : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestConfigVariables() - : TestCommandBridge("TestConfigVariables") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("arg1", 0, UINT8_MAX, &mArg1); - AddArgument("returnValueWithArg1", 0, UINT8_MAX, &mReturnValueWithArg1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestConfigVariables() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestConfigVariables\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestConfigVariables\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mArg1; - chip::Optional mReturnValueWithArg1; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull TestAddArgumentDefaultValue; - - CHIP_ERROR TestSendTestAddArgumentsCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - { - TestAddArgumentDefaultValue = values.returnValue; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = mArg1.HasValue() ? [NSNumber numberWithUnsignedChar:mArg1.Value()] : [NSNumber numberWithUnsignedChar:5U]; - params.arg2 = - [TestAddArgumentDefaultValue copy]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, mReturnValueWithArg1.HasValue() ? mReturnValueWithArg1.Value() : 25U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDescriptorCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDescriptorCluster() - : TestCommandBridge("TestDescriptorCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDescriptorCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDescriptorCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDescriptorCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Device list\n"); - err = TestReadAttributeDeviceList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute Server list\n"); - err = TestReadAttributeServerList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute Client list\n"); - err = TestReadAttributeClientList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute Parts list\n"); - err = TestReadAttributePartsList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute ClusterRevision\n"); - err = TestReadAttributeClusterRevision_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute Tag list\n"); - err = TestReadAttributeTagList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read feature map Attribute\n"); - err = TestReadFeatureMapAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeDeviceList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Device list: Error: %@", err); - } else { - NSLog(@"Read attribute Device list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DeviceTypeList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).deviceType, 17UL)); - VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).revision, 1U)); - VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).deviceType, 22UL)); - VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).revision, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeServerList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeServerListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Server list: Error: %@", err); - } else { - NSLog(@"Read attribute Server list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ServerList", [actualValue count], static_cast(28))); - VerifyOrReturn(CheckValue("", actualValue[0], 3UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 29UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 30UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 31UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 40UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 42UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 43UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 44UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 45UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 46UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 47UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 48UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 49UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 50UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 51UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 52UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 53UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 54UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 55UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 56UL)); - VerifyOrReturn(CheckValue("", actualValue[21], 60UL)); - VerifyOrReturn(CheckValue("", actualValue[22], 62UL)); - VerifyOrReturn(CheckValue("", actualValue[23], 63UL)); - VerifyOrReturn(CheckValue("", actualValue[24], 64UL)); - VerifyOrReturn(CheckValue("", actualValue[25], 65UL)); - VerifyOrReturn(CheckValue("", actualValue[26], 1029UL)); - VerifyOrReturn(CheckValue("", actualValue[27], 4294048774UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeClientList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClientListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Client list: Error: %@", err); - } else { - NSLog(@"Read attribute Client list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClientList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePartsList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePartsListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Parts list: Error: %@", err); - } else { - NSLog(@"Read attribute Parts list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PartsList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeClusterRevision_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ClusterRevision: Error: %@", err); - } else { - NSLog(@"Read attribute ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeTagList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTagListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Tag list: Error: %@", err); - } else { - NSLog(@"Read attribute Tag list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TagList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).mfgCode)); - VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).namespaceID, 7U)); - VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).tag, 0U)); - VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).mfgCode)); - VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).namespaceID, 8U)); - VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).tag, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFeatureMapAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read feature map Attribute: Error: %@", err); - } else { - NSLog(@"Read feature map Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestFabricRemovalWhileSubscribed : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestFabricRemovalWhileSubscribed() - : TestCommandBridge("TestFabricRemovalWhileSubscribed") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestFabricRemovalWhileSubscribed() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestFabricRemovalWhileSubscribed\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestFabricRemovalWhileSubscribed\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Open commissioning window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from beta\n"); - err = TestCommissionFromBeta_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Report: Subscribe Fabrics Attribute from beta\n"); - err = TestReportSubscribeFabricsAttributeFromBeta_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Subscribe Fabrics Attribute from beta\n"); - err = TestSubscribeFabricsAttributeFromBeta_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Remove single own fabric\n"); - err = TestRemoveSingleOwnFabric_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open commissioning window from alpha: Error: %@", err); - } else { - NSLog(@"Open commissioning window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_4() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = 74565ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = 74565ULL; - return WaitForCommissionee("beta", value); - } - bool testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = nil; - - CHIP_ERROR TestReportSubscribeFabricsAttributeFromBeta_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe Fabrics Attribute from beta: Error: %@", err); - } else { - NSLog(@"Report: Subscribe Fabrics Attribute from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); - testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeFabricsAttributeFromBeta_7() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeFabricsWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe Fabrics Attribute from beta: Error: %@", err); - } else { - NSLog(@"Subscribe Fabrics Attribute from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - != nil) { - ResponseHandler callback = test_TestFabricRemovalWhileSubscribed_Fabrics_Reported; - test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSingleOwnFabric_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [ourFabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove single own fabric: Error: %@", err); - } else { - NSLog(@"Remove single own fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestGeneralCommissioning : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestGeneralCommissioning() - : TestCommandBridge("TestGeneralCommissioning") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestGeneralCommissioning() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGeneralCommissioning\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGeneralCommissioning\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write Breadcrumb (1/2)\n"); - err = TestWriteBreadcrumb12_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read back Breadcrumb (1/2)\n"); - err = TestReadBackBreadcrumb12_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write Breadcrumb (2/2)\n"); - err = TestWriteBreadcrumb22_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back Breadcrumb (2/2)\n"); - err = TestReadBackBreadcrumb22_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Reboot to reset Breadcrumb\n"); - err = TestRebootToResetBreadcrumb_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Connect to the device again\n"); - err = TestConnectToTheDeviceAgain_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read back Breadcrumb after reboot and ensure it was not persisted\n"); - err = TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Set Breadcrumb to nonzero value\n"); - err = TestSetBreadcrumbToNonzeroValue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Check Breadcrumb set worked\n"); - err = TestCheckBreadcrumbSetWorked_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Send CommissioningComplete without armed fail-safe\n"); - err = TestSendCommissioningCompleteWithoutArmedFailSafe_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check Breadcrumb was not touched by invalid CommissioningComplete\n"); - err = TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Try to arm fail-safe\n"); - err = TestTryToArmFailSafe_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Check Breadcrumb was not touched by ArmFailSafe with commissioning window open\n"); - err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Reset Breadcrumb to 0 so we can commission\n"); - err = TestResetBreadcrumbTo0SoWeCanCommission_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Commission from beta\n"); - err = TestCommissionFromBeta_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Arm fail-safe\n"); - err = TestArmFailSafe_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check Breadcrumb was properly set by ArmFailSafe\n"); - err = TestCheckBreadcrumbWasProperlySetByArmFailSafe_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Try to arm fail-safe from wrong fabric\n"); - err = TestTryToArmFailSafeFromWrongFabric_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed\n"); - err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Send CommissioningComplete from wrong fabric\n"); - err = TestSendCommissioningCompleteFromWrongFabric_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Check Breadcrumb was not touched by CommissioningComplete from wrong fabric\n"); - err = TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Close out the fail-safe gracefully\n"); - err = TestCloseOutTheFailSafeGracefully_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check Breadcrumb was reset to 0 by CommissioningComplete\n"); - err = TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Arm fail-safe again\n"); - err = TestArmFailSafeAgain_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Check Breadcrumb was set by arming fail-safe again\n"); - err = TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Force-expire the fail-safe\n"); - err = TestForceExpireTheFailSafe_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Check Breadcrumb was reset by expiring the fail-safe\n"); - err = TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Validate presence of SupportsConcurrentConnection\n"); - err = TestValidatePresenceOfSupportsConcurrentConnection_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read original regulatory location\n"); - err = TestReadOriginalRegulatoryLocation_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Read original location\n"); - err = TestReadOriginalLocation_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Try to SetRegulatoryConfig with 0-length country code\n"); - err = TestTryToSetRegulatoryConfigWith0LengthCountryCode_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read back location\n"); - err = TestReadBackLocation_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Try to SetRegulatoryConfig with length-1 country code\n"); - err = TestTryToSetRegulatoryConfigWithLength1CountryCode_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read back location second time\n"); - err = TestReadBackLocationSecondTime_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Try to SetRegulatoryConfig with length-2 country code\n"); - err = TestTryToSetRegulatoryConfigWithLength2CountryCode_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read back location third time\n"); - err = TestReadBackLocationThirdTime_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Restore initial values\n"); - err = TestRestoreInitialValues_39(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 40; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteBreadcrumb12_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:137438953472ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Breadcrumb (1/2): Error: %@", err); - } else { - NSLog(@"Write Breadcrumb (1/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackBreadcrumb12_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb (1/2): Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb (1/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 137438953472ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBreadcrumb22_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:81ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Breadcrumb (2/2): Error: %@", err); - } else { - NSLog(@"Write Breadcrumb (2/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackBreadcrumb22_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb (2/2): Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb (2/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 81ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootToResetBreadcrumb_5() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestConnectToTheDeviceAgain_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetBreadcrumbToNonzeroValue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Breadcrumb to nonzero value: Error: %@", err); - } else { - NSLog(@"Set Breadcrumb to nonzero value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbSetWorked_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb set worked: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb set worked: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendCommissioningCompleteWithoutArmedFailSafe_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send CommissioningComplete without armed fail-safe: Error: %@", err); - } else { - NSLog(@"Send CommissioningComplete without armed fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToArmFailSafe_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:10U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:5000ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to arm fail-safe: Error: %@", err); - } else { - NSLog(@"Try to arm fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetBreadcrumbTo0SoWeCanCommission_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Breadcrumb to 0 so we can commission: Error: %@", err); - } else { - NSLog(@"Reset Breadcrumb to 0 so we can commission: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_16() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = 74565ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = 74565ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestArmFailSafe_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:500U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:2ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Arm fail-safe: Error: %@", err); - } else { - NSLog(@"Arm fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasProperlySetByArmFailSafe_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToArmFailSafeFromWrongFabric_20() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:10U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:5000ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to arm fail-safe from wrong fabric: Error: %@", err); - } else { - NSLog(@"Try to arm fail-safe from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendCommissioningCompleteFromWrongFabric_22() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send CommissioningComplete from wrong fabric: Error: %@", err); - } else { - NSLog(@"Send CommissioningComplete from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseOutTheFailSafeGracefully_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close out the fail-safe gracefully: Error: %@", err); - } else { - NSLog(@"Close out the fail-safe gracefully: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestArmFailSafeAgain_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:500U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:3ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Arm fail-safe again: Error: %@", err); - } else { - NSLog(@"Arm fail-safe again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was set by arming fail-safe again: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was set by arming fail-safe again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 3ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestForceExpireTheFailSafe_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:0U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:4ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Force-expire the fail-safe: Error: %@", err); - } else { - NSLog(@"Force-expire the fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidatePresenceOfSupportsConcurrentConnection_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate presence of SupportsConcurrentConnection: Error: %@", err); - } else { - NSLog(@"Validate presence of SupportsConcurrentConnection: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull originalRegulatoryConfig; - - CHIP_ERROR TestReadOriginalRegulatoryLocation_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read original regulatory location: Error: %@", err); - } else { - NSLog(@"Read original regulatory location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - originalRegulatoryConfig = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull originalLocation; - - CHIP_ERROR TestReadOriginalLocation_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read original location: Error: %@", err); - } else { - NSLog(@"Read original location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"XX")); - } - { - originalLocation = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWith0LengthCountryCode_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @""; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocation_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location: Error: %@", err); - } else { - NSLog(@"Read back location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWithLength1CountryCode_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @"U"; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocationSecondTime_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location second time: Error: %@", err); - } else { - NSLog(@"Read back location second time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWithLength2CountryCode_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @"US"; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - { - id actualValue = values.debugText; - VerifyOrReturn(CheckValueAsString("DebugText", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocationThirdTime_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location third time: Error: %@", err); - } else { - NSLog(@"Read back location third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"US")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreInitialValues_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [originalRegulatoryConfig copy]; - params.countryCode = - [originalLocation copy]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore initial values: Error: %@", err); - } else { - NSLog(@"Restore initial values: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestIdentifyCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestIdentifyCluster() - : TestCommandBridge("TestIdentifyCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestIdentifyCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestIdentifyCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestIdentifyCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Identify command and expect success response\n"); - err = TestSendIdentifyCommandAndExpectSuccessResponse_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendIdentifyCommandAndExpectSuccessResponse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:0U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Identify command and expect success response: Error: %@", err); - } else { - NSLog(@"Send Identify command and expect success response: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestOperationalCredentialsCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestOperationalCredentialsCluster() - : TestCommandBridge("TestOperationalCredentialsCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestOperationalCredentialsCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestOperationalCredentialsCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestOperationalCredentialsCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of supported fabrics\n"); - err = TestReadNumberOfSupportedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Remove nonexistent fabric\n"); - err = TestRemoveNonexistentFabric_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read fabric list before setting label\n"); - err = TestReadFabricListBeforeSettingLabel_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Set the fabric label\n"); - err = TestSetTheFabricLabel_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read fabric list after setting label\n"); - err = TestReadFabricListAfterSettingLabel_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfSupportedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of supported fabrics: Error: %@", err); - } else { - NSLog(@"Read number of supported fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedFabrics", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("supportedFabrics", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("commissionedFabrics", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveNonexistentFabric_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [NSNumber numberWithUnsignedChar:243U]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove nonexistent fabric: Error: %@", err); - } else { - NSLog(@"Remove nonexistent fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.statusCode; - VerifyOrReturn(CheckValue("StatusCode", actualValue, 11U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFabricListBeforeSettingLabel_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fabric list before setting label: Error: %@", err); - } else { - NSLog(@"Read fabric list before setting label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); - VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTheFabricLabel_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"Batcave"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set the fabric label: Error: %@", err); - } else { - NSLog(@"Set the fabric label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.statusCode; - VerifyOrReturn(CheckValue("StatusCode", actualValue, 0U)); - } - - { - id actualValue = values.fabricIndex; - VerifyOrReturn(CheckValue("FabricIndex", actualValue, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFabricListAfterSettingLabel_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fabric list after setting label: Error: %@", err); - } else { - NSLog(@"Read fabric list after setting label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"Batcave")); - VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestModeSelectCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestModeSelectCluster() - : TestCommandBridge("TestModeSelectCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestModeSelectCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestModeSelectCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestModeSelectCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Description\n"); - err = TestReadDescription_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read StandardNamespace\n"); - err = TestReadStandardNamespace_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read SupportedModes\n"); - err = TestReadSupportedModes_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read CurrentMode\n"); - err = TestReadCurrentMode_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read StartUpMode\n"); - err = TestReadStartUpMode_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnMode\n"); - err = TestReadOnMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Change to Supported Mode\n"); - err = TestChangeToSupportedMode_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify Current Mode Change\n"); - err = TestVerifyCurrentModeChange_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Change to Unsupported Mode\n"); - err = TestChangeToUnsupportedMode_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Toggle OnOff\n"); - err = TestToggleOnOff_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Toggle OnOff\n"); - err = TestToggleOnOff_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify Current Mode does not change when OnMode is null\n"); - err = TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Change to Unsupported OnMode\n"); - err = TestChangeToUnsupportedOnMode_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Change OnMode\n"); - err = TestChangeOnMode_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Verify OnMode\n"); - err = TestVerifyOnMode_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Toggle OnOff\n"); - err = TestToggleOnOff_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Toggle OnOff\n"); - err = TestToggleOnOff_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify Current Mode Changes if OnMode is not null\n"); - err = TestVerifyCurrentModeChangesIfOnModeIsNotNull_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Change to Unsupported StartUp Mode\n"); - err = TestChangeToUnsupportedStartUpMode_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Change to Supported StartUp Mode\n"); - err = TestChangeToSupportedStartUpMode_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Verify StartUp Mode Change\n"); - err = TestVerifyStartUpModeChange_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Change CurrentMode to another value\n"); - err = TestChangeCurrentModeToAnotherValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Change On Mode\n"); - err = TestChangeOnMode_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Set StartUpOnOff\n"); - err = TestSetStartUpOnOff_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Reboot target device\n"); - err = TestRebootTargetDevice_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Verify Current Mode Change based on OnMode, as it overwrites StartUpMode\n"); - err = TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Change On Mode to Null\n"); - err = TestChangeOnModeToNull_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Reboot target device\n"); - err = TestRebootTargetDevice_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Verify Current Mode Change based on new StartUp Mode\n"); - err = TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 32; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadDescription_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Description: Error: %@", err); - } else { - NSLog(@"Read Description: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Description", actualValue, @"Coffee")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStandardNamespace_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStandardNamespaceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read StandardNamespace: Error: %@", err); - } else { - NSLog(@"Read StandardNamespace: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StandardNamespace", actualValue)); - VerifyOrReturn(CheckValue("StandardNamespace", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadSupportedModes_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read SupportedModes: Error: %@", err); - } else { - NSLog(@"Read SupportedModes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedModes", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).label, @"Black")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).mode, 0U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags[0]).value, 0U)); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).label, @"Cappuccino")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).mode, 4U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags[0]).value, 0U)); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).label, @"Espresso")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).mode, 7U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags[0]).value, 0U)); - } - - VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 3)); - VerifyOrReturn(CheckConstraintMaxLength("supportedModes", value, 3)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentMode_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read CurrentMode: Error: %@", err); - } else { - NSLog(@"Read CurrentMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStartUpMode_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read StartUpMode: Error: %@", err); - } else { - NSLog(@"Read StartUpMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); - VerifyOrReturn(CheckValue("StartUpMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOnMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnMode: Error: %@", err); - } else { - NSLog(@"Read OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("OnMode", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToSupportedMode_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:4U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Supported Mode: Error: %@", err); - } else { - NSLog(@"Change to Supported Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull currentModeBeforeToggle; - - CHIP_ERROR TestVerifyCurrentModeChange_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); - } - { - currentModeBeforeToggle = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedMode_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:2U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported Mode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode does not change when OnMode is null: Error: %@", err); - } else { - NSLog(@"Verify Current Mode does not change when OnMode is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, currentModeBeforeToggle)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedOnMode_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported OnMode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnMode_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change OnMode: Error: %@", err); - } else { - NSLog(@"Change OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnModeValue; - - CHIP_ERROR TestVerifyOnMode_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify OnMode: Error: %@", err); - } else { - NSLog(@"Verify OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnMode", actualValue)); - VerifyOrReturn(CheckValue("OnMode", actualValue, 7U)); - } - { - OnModeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCurrentModeChangesIfOnModeIsNotNull_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Changes if OnMode is not null: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Changes if OnMode is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, OnModeValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedStartUpMode_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpModeArgument; - startUpModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported StartUp Mode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToSupportedStartUpMode_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpModeArgument; - startUpModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Supported StartUp Mode: Error: %@", err); - } else { - NSLog(@"Change to Supported StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyStartUpModeChange_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify StartUp Mode Change: Error: %@", err); - } else { - NSLog(@"Verify StartUp Mode Change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); - VerifyOrReturn(CheckValue("StartUpMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeCurrentModeToAnotherValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change CurrentMode to another value: Error: %@", err); - } else { - NSLog(@"Change CurrentMode to another value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnMode_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change On Mode: Error: %@", err); - } else { - NSLog(@"Change On Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetStartUpOnOff_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set StartUpOnOff: Error: %@", err); - } else { - NSLog(@"Set StartUpOnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_25() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnModeToNull_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = nil; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change On Mode to Null: Error: %@", err); - } else { - NSLog(@"Change On Mode to Null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_29() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change based on new StartUp Mode: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change based on new StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestTemperatureControl : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestTemperatureControl() - : TestCommandBridge("TestTemperatureControl") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestTemperatureControl() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestTemperatureControl\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestTemperatureControl\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read supported temperature levels\n"); - err = TestReadSupportedTemperatureLevels_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read selected temperature level\n"); - err = TestReadSelectedTemperatureLevel_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Set temperature level to different level\n"); - err = TestSetTemperatureLevelToDifferentLevel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back selected temperature level\n"); - err = TestReadBackSelectedTemperatureLevel_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Set temperature level to different level\n"); - err = TestSetTemperatureLevelToDifferentLevel_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read back selected temperature level\n"); - err = TestReadBackSelectedTemperatureLevel_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadSupportedTemperatureLevels_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read supported temperature levels: Error: %@", err); - } else { - NSLog(@"Read supported temperature levels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedTemperatureLevels", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], @"Hot")); - VerifyOrReturn(CheckValueAsString("", actualValue[1], @"Warm")); - VerifyOrReturn(CheckValueAsString("", actualValue[2], @"Freezing")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadSelectedTemperatureLevel_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read selected temperature level: Error: %@", err); - } else { - NSLog(@"Read selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set temperature level to different level: Error: %@", err); - } else { - NSLog(@"Set temperature level to different level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSelectedTemperatureLevel_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back selected temperature level: Error: %@", err); - } else { - NSLog(@"Read back selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set temperature level to different level: Error: %@", err); - } else { - NSLog(@"Set temperature level to different level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSelectedTemperatureLevel_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back selected temperature level: Error: %@", err); - } else { - NSLog(@"Read back selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSelfFabricRemoval : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSelfFabricRemoval() - : TestCommandBridge("TestSelfFabricRemoval") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSelfFabricRemoval() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSelfFabricRemoval\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSelfFabricRemoval\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Remove single own fabric\n"); - err = TestRemoveSingleOwnFabric_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSingleOwnFabric_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [ourFabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove single own fabric: Error: %@", err); - } else { - NSLog(@"Remove single own fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSystemCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSystemCommands() - : TestCommandBridge("TestSystemCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("secondNodeId", 0, UINT64_MAX, &mSecondNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSystemCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSystemCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSystemCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Start the default accessory with no command line options\n"); - err = TestStartTheDefaultAccessoryWithNoCommandLineOptions_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Stop the default accessory by key\n"); - err = TestStopTheDefaultAccessoryByKey_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Start the default accessory with discriminator command line option\n"); - err = TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Start the default accessory with discriminator and port command line options\n"); - err = TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Start the default accessory with minCommissioningTimeout only\n"); - err = TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Start the default accessory by key with all command line options\n"); - err = TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Start a second accessory with all command line options\n"); - err = TestStartASecondAccessoryWithAllCommandLineOptions_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Commission second accessory from alpha\n"); - err = TestCommissionSecondAccessoryFromAlpha_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the second commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Stop the second accessory\n"); - err = TestStopTheSecondAccessory_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Start a second accessory with different KVS\n"); - err = TestStartASecondAccessoryWithDifferentKvs_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Commission second accessory with new KVS from alpha\n"); - err = TestCommissionSecondAccessoryWithNewKvsFromAlpha_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the second commissioned device with new KVS to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Reboot the default accessory\n"); - err = TestRebootTheDefaultAccessory_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Reboot the default accessory by key\n"); - err = TestRebootTheDefaultAccessoryByKey_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Reboot the second accessory\n"); - err = TestRebootTheSecondAccessory_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Factory Reset the default accessory\n"); - err = TestFactoryResetTheDefaultAccessory_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Factory Reset the default accessory by key\n"); - err = TestFactoryResetTheDefaultAccessoryByKey_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Factory Reset the second accessory\n"); - err = TestFactoryResetTheSecondAccessory_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Commission the now-reset second accessory from alpha\n"); - err = TestCommissionTheNowResetSecondAccessoryFromAlpha_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait for the second commissioned device (after reset) to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mSecondNodeId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_1() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithNoCommandLineOptions_2() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessoryByKey_3() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_5() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - value.port.Emplace(); - value.port.Value() = 5560U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_7() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.minCommissioningTimeout.Emplace(); - value.minCommissioningTimeout.Value() = 10U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_9() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - value.port.Emplace(); - value.port.Value() = 5560U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_defaultgarbage: not in length on purpose", 21); - value.minCommissioningTimeout.Emplace(); - value.minCommissioningTimeout.Value() = 10U; - return Start("alpha", value); - } - - CHIP_ERROR TestStartASecondAccessoryWithAllCommandLineOptions_11() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - value.discriminator.Emplace(); - value.discriminator.Value() = 50U; - value.port.Emplace(); - value.port.Value() = 5561U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_lockgarbage: not in length on purpose", 18); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionSecondAccessoryFromAlpha_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStopTheSecondAccessory_14() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return Stop("alpha", value); - } - - CHIP_ERROR TestStartASecondAccessoryWithDifferentKvs_15() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - value.discriminator.Emplace(); - value.discriminator.Value() = 50U; - value.port.Emplace(); - value.port.Value() = 5561U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_lock2garbage: not in length on purpose", 19); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionSecondAccessoryWithNewKvsFromAlpha_16() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestRebootTheDefaultAccessory_18() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestRebootTheDefaultAccessoryByKey_19() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return Reboot("alpha", value); - } - - CHIP_ERROR TestRebootTheSecondAccessory_20() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return Reboot("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheDefaultAccessory_21() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheDefaultAccessoryByKey_22() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheSecondAccessory_23() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestCommissionTheNowResetSecondAccessoryFromAlpha_24() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } -}; - -class TestBinding : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestBinding() - : TestCommandBridge("TestBinding") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestBinding() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestBinding\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestBinding\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write empty binding table\n"); - err = TestWriteEmptyBindingTable_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read empty binding table\n"); - err = TestReadEmptyBindingTable_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write invalid binding table\n"); - err = TestWriteInvalidBindingTable_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write binding table (endpoint 1)\n"); - err = TestWriteBindingTableEndpoint1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read binding table (endpoint 1)\n"); - err = TestReadBindingTableEndpoint1_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Write binding table (endpoint 0)\n"); - err = TestWriteBindingTableEndpoint0_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read binding table (endpoint 0)\n"); - err = TestReadBindingTableEndpoint0_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify endpoint 1 not changed\n"); - err = TestVerifyEndpoint1NotChanged_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write over-long binding table on endpoint 1\n"); - err = TestWriteOverLongBindingTableOnEndpoint1_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteEmptyBindingTable_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write empty binding table: Error: %@", err); - } else { - NSLog(@"Write empty binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEmptyBindingTable_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read empty binding table: Error: %@", err); - } else { - NSLog(@"Read empty binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteInvalidBindingTable_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).group = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write invalid binding table: Error: %@", err); - } else { - NSLog(@"Write invalid binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBindingTableEndpoint1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).group = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).node = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write binding table (endpoint 1): Error: %@", err); - } else { - NSLog(@"Write binding table (endpoint 1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBindingTableEndpoint1_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read binding table (endpoint 1): Error: %@", err); - } else { - NSLog(@"Read binding table (endpoint 1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); - VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBindingTableEndpoint0_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).node = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write binding table (endpoint 0): Error: %@", err); - } else { - NSLog(@"Write binding table (endpoint 0): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBindingTableEndpoint0_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read binding table (endpoint 0): Error: %@", err); - } else { - NSLog(@"Read binding table (endpoint 0): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[0]).node, 3ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[0]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyEndpoint1NotChanged_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify endpoint 1 not changed: Error: %@", err); - } else { - NSLog(@"Verify endpoint 1 not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); - VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOverLongBindingTableOnEndpoint1_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:2U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).node = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).node = - [NSNumber numberWithUnsignedLongLong:4ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).endpoint = - [NSNumber numberWithUnsignedShort:4U]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[4] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).node = - [NSNumber numberWithUnsignedLongLong:5ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).endpoint = - [NSNumber numberWithUnsignedShort:5U]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[5] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).node = - [NSNumber numberWithUnsignedLongLong:6ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).endpoint = - [NSNumber numberWithUnsignedShort:6U]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[6] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).node = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).endpoint = - [NSNumber numberWithUnsignedShort:7U]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[7] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).node = - [NSNumber numberWithUnsignedLongLong:8ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[8] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).node = - [NSNumber numberWithUnsignedLongLong:9ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).endpoint = - [NSNumber numberWithUnsignedShort:9U]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[9] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).node = - [NSNumber numberWithUnsignedLongLong:10ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).endpoint = - [NSNumber numberWithUnsignedShort:10U]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[10] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).node = - [NSNumber numberWithUnsignedLongLong:11ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write over-long binding table on endpoint 1: Error: %@", err); - } else { - NSLog(@"Write over-long binding table on endpoint 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestUserLabelCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestUserLabelCluster() - : TestCommandBridge("TestUserLabelCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestUserLabelCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestUserLabelCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Commit User Label List\n"); - err = TestCommitUserLabelList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify committed User Label List\n"); - err = TestVerifyCommittedUserLabelList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Clear User Label List\n"); - err = TestClearUserLabelList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read User Label List\n"); - err = TestReadUserLabelList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write User Label List\n"); - err = TestWriteUserLabelList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Reboot target device\n"); - err = TestRebootTargetDevice_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify User Label List after reboot\n"); - err = TestVerifyUserLabelListAfterReboot_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCommitUserLabelList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"South"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"down"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Commit User Label List: Error: %@", err); - } else { - NSLog(@"Commit User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCommittedUserLabelList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify committed User Label List: Error: %@", err); - } else { - NSLog(@"Verify committed User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"South")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"down")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserLabelList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear User Label List: Error: %@", err); - } else { - NSLog(@"Clear User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadUserLabelList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read User Label List: Error: %@", err); - } else { - NSLog(@"Read User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteUserLabelList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"North"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"5"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"up"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write User Label List: Error: %@", err); - } else { - NSLog(@"Write User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_6() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyUserLabelListAfterReboot_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify User Label List after reboot: Error: %@", err); - } else { - NSLog(@"Verify User Label List after reboot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"North")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"5")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"up")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestUserLabelClusterConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestUserLabelClusterConstraints() - : TestCommandBridge("TestUserLabelClusterConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestUserLabelClusterConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestUserLabelClusterConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelClusterConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Attempt to write overly long item for label\n"); - err = TestAttemptToWriteOverlyLongItemForLabel_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Attempt to write overly long item for value\n"); - err = TestAttemptToWriteOverlyLongItemForValue_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestAttemptToWriteOverlyLongItemForLabel_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"this is longer than sixteen characters"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Attempt to write overly long item for label: Error: %@", err); - } else { - NSLog(@"Attempt to write overly long item for label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAttemptToWriteOverlyLongItemForValue_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"test"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"this is longer than sixteen characters"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Attempt to write overly long item for value: Error: %@", err); - } else { - NSLog(@"Attempt to write overly long item for value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestArmFailSafe : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestArmFailSafe() - : TestCommandBridge("TestArmFailSafe") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestArmFailSafe() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestArmFailSafe\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestArmFailSafe\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Reboot target device\n"); - err = TestRebootTargetDevice_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for the alpha device to be retrieved \n"); - err = TestWaitForTheAlphaDeviceToBeRetrieved_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Query fabrics list\n"); - err = TestQueryFabricsList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : ArmFailSafe on target device with timeout 0\n"); - err = TestArmFailSafeOnTargetDeviceWithTimeout0_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Reads NodeLabel mandatory attribute of target device\n"); - err = TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Invoke AddTrustedRootCertificate without fail-safe\n"); - err = TestInvokeAddTrustedRootCertificateWithoutFailSafe_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Invoke AddNOC without fail-safe\n"); - err = TestInvokeAddNOCWithoutFailSafe_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Invoke UpdateNOC without fail-safe\n"); - err = TestInvokeUpdateNOCWithoutFailSafe_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Invoke CSRRequest without fail-safe\n"); - err = TestInvokeCSRRequestWithoutFailSafe_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestRebootTargetDevice_0() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheAlphaDeviceToBeRetrieved_1() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestQueryFabricsList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Query fabrics list: Error: %@", err); - } else { - NSLog(@"Query fabrics list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); - } - - VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestArmFailSafeOnTargetDeviceWithTimeout0_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:0U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"ArmFailSafe on target device with timeout 0: Error: %@", err); - } else { - NSLog(@"ArmFailSafe on target device with timeout 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads NodeLabel mandatory attribute of target device: Error: %@", err); - } else { - NSLog(@"Reads NodeLabel mandatory attribute of target device: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeAddTrustedRootCertificateWithoutFailSafe_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterAddTrustedRootCertificateParams alloc] init]; - params.rootCACertificate = - [[NSData alloc] initWithBytes:"00000000" length:8]; - [cluster addTrustedRootCertificateWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeAddNOCWithoutFailSafe_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterAddNOCParams alloc] init]; - params.nocValue = - [[NSData alloc] initWithBytes:"00112233" length:8]; - params.ipkValue = - [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:16]; - params.caseAdminSubject = - [NSNumber numberWithUnsignedLongLong:1234ULL]; - params.adminVendorId = - [NSNumber numberWithUnsignedShort:65521U]; - [cluster addNOCWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke AddNOC without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke AddNOC without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeUpdateNOCWithoutFailSafe_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateNOCParams alloc] init]; - params.nocValue = - [[NSData alloc] initWithBytes:"00112233" length:8]; - [cluster updateNOCWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke UpdateNOC without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke UpdateNOC without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeCSRRequestWithoutFailSafe_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterCSRRequestParams alloc] init]; - params.csrNonce = - [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:32]; - [cluster CSRRequestWithParams:params completion: - ^(MTROperationalCredentialsClusterCSRResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke CSRRequest without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke CSRRequest without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestFanControl : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestFanControl() - : TestCommandBridge("TestFanControl") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestFanControl() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestFanControl\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestFanControl\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write fan mode\n"); - err = TestWriteFanMode_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read back fan mode\n"); - err = TestReadBackFanMode_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write percent setting\n"); - err = TestWritePercentSetting_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back percent setting\n"); - err = TestReadBackPercentSetting_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read back speed current\n"); - err = TestReadBackSpeedCurrent_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write percent setting\n"); - err = TestWritePercentSetting_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read back percent setting\n"); - err = TestReadBackPercentSetting_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write speed setting\n"); - err = TestWriteSpeedSetting_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read back percent setting\n"); - err = TestReadBackPercentSetting_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read back percent current\n"); - err = TestReadBackPercentCurrent_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write speed setting\n"); - err = TestWriteSpeedSetting_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write fan mode\n"); - err = TestWriteFanMode_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read back percent setting\n"); - err = TestReadBackPercentSetting_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read back percent current\n"); - err = TestReadBackPercentCurrent_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read back speed current\n"); - err = TestReadBackSpeedCurrent_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Write fan mode\n"); - err = TestWriteFanMode_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read back percent setting\n"); - err = TestReadBackPercentSetting_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteFanMode_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackFanMode_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back fan mode: Error: %@", err); - } else { - NSLog(@"Read back fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FanMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritePercentSetting_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = - [NSNumber numberWithUnsignedChar:84U]; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write percent setting: Error: %@", err); - } else { - NSLog(@"Write percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedCurrent_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed current: Error: %@", err); - } else { - NSLog(@"Read back speed current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritePercentSetting_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = nil; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write percent setting: Error: %@", err); - } else { - NSLog(@"Write percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSpeedSetting_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id speedSettingArgument; - speedSettingArgument = - [NSNumber numberWithUnsignedChar:73U]; - [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write speed setting: Error: %@", err); - } else { - NSLog(@"Write speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentCurrent_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent current: Error: %@", err); - } else { - NSLog(@"Read back percent current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSpeedSetting_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id speedSettingArgument; - speedSettingArgument = nil; - [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write speed setting: Error: %@", err); - } else { - NSLog(@"Write speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteFanMode_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentCurrent_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent current: Error: %@", err); - } else { - NSLog(@"Read back percent current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedCurrent_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed current: Error: %@", err); - } else { - NSLog(@"Read back speed current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteFanMode_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PercentSetting", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("SpeedSetting", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestAccessControlConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestAccessControlConstraints() - : TestCommandBridge("TestAccessControlConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestAccessControlConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestAccessControlConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Constraint error: PASE reserved for future (TC-ACL-2.4 step 29)\n"); - err = TestConstraintErrorPaseReservedForFutureTcAcl24Step29_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31)\n"); - err = TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Constraint error: Invalid auth mode (TC-ACL-2.4 step 33)\n"); - err = TestConstraintErrorInvalidAuthModeTcAcl24Step33_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Constraint error: Invalid subject (TC-ACL-2.4 step 34)\n"); - err = TestConstraintErrorInvalidSubjectTcAcl24Step34_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Constraint error: Invalid target (TC-ACL-2.4 step 38)\n"); - err = TestConstraintErrorInvalidTargetTcAcl24Step38_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42)\n"); - err = TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Constraint error: Invalid privilege value step 32)\n"); - err = TestConstraintErrorInvalidPrivilegeValueStep32_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - 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)); - break; - 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; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestConstraintErrorPaseReservedForFutureTcAcl24Step29_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:1U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Error: %@", err); - } else { - NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidAuthModeTcAcl24Step33_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:4U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubjectTcAcl24Step34_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidTargetTcAcl24Step38_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:22U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = - [NSNumber numberWithUnsignedInt:33UL]; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Error: %@", err); - } else { - NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidPrivilegeValueStep32_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:6U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid privilege value step 32): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid privilege value step 32): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744060824649728ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744073709486080ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestLevelControlWithOnOffDependency : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestLevelControlWithOnOffDependency() - : TestCommandBridge("TestLevelControlWithOnOffDependency") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestLevelControlWithOnOffDependency() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestLevelControlWithOnOffDependency\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestLevelControlWithOnOffDependency\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Sends a MoveToLevel command to set CurrentLevel to min value\n"); - err = TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 100 ms\n"); - err = TestWait100Ms_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Reads CurrentLevel attribute from DUT\n"); - err = TestReadsCurrentLevelAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write OnOffTransitionTime attribute\n"); - err = TestWriteOnOffTransitionTimeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 100 ms\n"); - err = TestWait100Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnOffTransitionTime attribute\n"); - err = TestReadOnOffTransitionTimeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write OnLevel attribute\n"); - err = TestWriteOnLevelAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 100 ms\n"); - err = TestWait100Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read OnLevel attribute\n"); - err = TestReadOnLevelAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read MinValue attribute\n"); - err = TestReadMinValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Send On Command\n"); - err = TestSendOnCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Check on/off attribute value is true after on command\n"); - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : If OnLevel is defined, check CurrentLevel is OnLevel value\n"); - err = TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Send Off Command\n"); - err = TestSendOffCommand_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : If OnLevel is defined, check CurrentLevel is min value\n"); - err = TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Sends a MoveToLevel command to set CurrentLevel to a mid value\n"); - err = TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 100 ms\n"); - err = TestWait100Ms_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Reads CurrentLevel attribute from DUT\n"); - err = TestReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Set OnLevel attribute to null\n"); - err = TestSetOnLevelAttributeToNull_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 100 ms\n"); - err = TestWait100Ms_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read OnLevel attribute\n"); - err = TestReadOnLevelAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Send On Command\n"); - err = TestSendOnCommand_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Check on/off attribute value is true after on command\n"); - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : If OnLevel is not defined, check CurrentLevel is restored\n"); - err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Send Off Command\n"); - err = TestSendOffCommand_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : If OnLevel is not defined, check CurrentLevel is restored\n"); - err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 33; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Error: %@", err); - } else { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOnOffTransitionTimeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Write OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnOffTransitionTimeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Read OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOnLevelAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Write OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnLevelAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Read OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); - VerifyOrReturn(CheckValue("OnLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMinValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read MinValue attribute: Error: %@", err); - } else { - NSLog(@"Read MinValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOnCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send On Command: Error: %@", err); - } else { - NSLog(@"Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Error: %@", err); - } else { - NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOffCommand_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Off Command: Error: %@", err); - } else { - NSLog(@"Send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 0UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Error: %@", err); - } else { - NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:127U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Error: %@", err); - } else { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetOnLevelAttributeToNull_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = nil; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set OnLevel attribute to null: Error: %@", err); - } else { - NSLog(@"Set OnLevel attribute to null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnLevelAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Read OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("OnLevel", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOnCommand_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send On Command: Error: %@", err); - } else { - NSLog(@"Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_27() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); - } else { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOffCommand_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Off Command: Error: %@", err); - } else { - NSLog(@"Send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_31() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 0UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); - } else { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCommissioningWindow : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCommissioningWindow() - : TestCommandBridge("TestCommissioningWindow") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("cluster", &mCluster); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCommissioningWindow() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCommissioningWindow\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCommissioningWindow\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get alpha's fabric index\n"); - err = TestGetAlphasFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check that commissioning window is not open\n"); - err = TestCheckThatCommissioningWindowIsNotOpen_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Check that there is no AdminFabricIndex\n"); - err = TestCheckThatThereIsNoAdminFabricIndex_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Check that there is no AdminVendorId\n"); - err = TestCheckThatThereIsNoAdminVendorId_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Check that commissioning window is open\n"); - err = TestCheckThatCommissioningWindowIsOpen_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check the AdminFabricIndex\n"); - err = TestCheckTheAdminFabricIndex_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Check the AdminVendorId is not null\n"); - err = TestCheckTheAdminVendorIdIsNotNull_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Close Commissioning Window\n"); - err = TestCloseCommissioningWindow_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Check that commissioning window is again not open\n"); - err = TestCheckThatCommissioningWindowIsAgainNotOpen_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check that again there is no AdminFabricIndex\n"); - err = TestCheckThatAgainThereIsNoAdminFabricIndex_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Check that again there is no AdminVendorId\n"); - err = TestCheckThatAgainThereIsNoAdminVendorId_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Open Commissioning Window from alpha again\n"); - err = TestOpenCommissioningWindowFromAlphaAgain_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Commission from beta\n"); - err = TestCommissionFromBeta_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check that commissioning window is not open for the third time\n"); - err = TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check that there is no AdminFabricIndex for the third time\n"); - err = TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check that there is no AdminVendorId for the third time\n"); - err = TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Get beta's fabric index\n"); - err = TestGetBetasFabricIndex_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Open Commissioning Window from beta\n"); - err = TestOpenCommissioningWindowFromBeta_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check that commissioning window is open again\n"); - err = TestCheckThatCommissioningWindowIsOpenAgain_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check the AdminFabricIndex again\n"); - err = TestCheckTheAdminFabricIndexAgain_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Check the AdminVendorId is not null again\n"); - err = TestCheckTheAdminVendorIdIsNotNullAgain_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Remove beta fabric\n"); - err = TestRemoveBetaFabric_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check that commissioning window is still open\n"); - err = TestCheckThatCommissioningWindowIsStillOpen_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Check the AdminFabricIndex got reset\n"); - err = TestCheckTheAdminFabricIndexGotReset_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Check the AdminVendorId did not get reset\n"); - err = TestCheckTheAdminVendorIdDidNotGetReset_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mNodeId2; - chip::Optional mEndpoint; - chip::Optional mCluster; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull alphaIndex; - - CHIP_ERROR TestGetAlphasFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get alpha's fabric index: Error: %@", err); - } else { - NSLog(@"Get alpha's fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - alphaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpen_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is not open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is not open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndex_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminVendorId_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsOpen_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndex_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (alphaIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, alphaIndex)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminVendorIdIsNotNull_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId is not null: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseCommissioningWindow_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close Commissioning Window: Error: %@", err); - } else { - NSLog(@"Close Commissioning Window: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsAgainNotOpen_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is again not open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is again not open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatAgainThereIsNoAdminFabricIndex_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that again there is no AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check that again there is no AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatAgainThereIsNoAdminVendorId_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that again there is no AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check that again there is no AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_14() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is not open for the third time: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is not open for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminFabricIndex for the third time: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminFabricIndex for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminVendorId for the third time: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminVendorId for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull betaIndex; - - CHIP_ERROR TestGetBetasFabricIndex_19() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get beta's fabric index: Error: %@", err); - } else { - NSLog(@"Get beta's fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - betaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromBeta_20() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from beta: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsOpenAgain_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is open again: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is open again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndexAgain_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex again: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (betaIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, betaIndex)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable adminVendorId; - - CHIP_ERROR TestCheckTheAdminVendorIdIsNotNullAgain_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId is not null again: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId is not null again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); - { - adminVendorId = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveBetaFabric_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [betaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove beta fabric: Error: %@", err); - } else { - NSLog(@"Remove beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsStillOpen_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is still open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is still open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndexGotReset_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex got reset: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex got reset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminVendorIdDidNotGetReset_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId did not get reset: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId did not get reset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (adminVendorId == nil) { - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); - VerifyOrReturn(CheckValue("AdminVendorId", actualValue, adminVendorId)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCommissionerNodeId : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCommissionerNodeId() - : TestCommandBridge("TestCommissionerNodeId") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("cluster", &mCluster); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCommissionerNodeId() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCommissionerNodeId\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCommissionerNodeId\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Commission from beta\n"); - err = TestCommissionFromBeta_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from gamma\n"); - err = TestCommissionFromGamma_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for gamma\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read the fabric ID from the alpha fabric\n"); - err = TestReadTheFabricIdFromTheAlphaFabric_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read the commissioner node ID from the alpha fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the fabric ID from the beta fabric\n"); - err = TestReadTheFabricIdFromTheBetaFabric_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read the commissioner node ID from the beta fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheBetaFabric_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the fabric ID from the gamma fabric\n"); - err = TestReadTheFabricIdFromTheGammaFabric_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read the commissioner node ID from the gamma fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheGammaFabric_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read the ACL from alpha and check commissioner node id\n"); - err = TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read the ACL from beta and check commissioner node id\n"); - err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read the ACL from gamma and check commissioner node id\n"); - err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Write the ACL using the commissioner node id value\n"); - err = TestWriteTheAclUsingTheCommissionerNodeIdValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write the ACL using the commissioner node id value\n"); - err = TestWriteTheAclUsingTheCommissionerNodeIdValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read the ACL from beta and check commissioner node id\n"); - err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read the ACL from gamma and check commissioner node id\n"); - err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Remove beta fabric\n"); - err = TestRemoveBetaFabric_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Remove gamma fabric\n"); - err = TestRemoveGammaFabric_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mEndpoint; - chip::Optional mCluster; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_2() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromGamma_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("gamma", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("gamma", value); - } - NSNumber * _Nonnull alphaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheAlphaFabric_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the alpha fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the alpha fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - alphaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdAlpha; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_8() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - NSNumber * _Nonnull betaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheBetaFabric_9() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the beta fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - betaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdBeta; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_10() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - NSNumber * _Nonnull gammaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheGammaFabric_11() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the gamma fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the gamma fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - gammaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdGamma; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheGammaFabric_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("gamma", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdGamma = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from alpha and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from alpha and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdAlpha)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, alphaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_14() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from beta and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_15() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_16() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdBeta copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [betaIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); - } else { - NSLog(@"Write the ACL using the commissioner node id value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_17() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdGamma copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [gammaIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); - } else { - NSLog(@"Write the ACL using the commissioner node id value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from beta and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_19() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveBetaFabric_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [betaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove beta fabric: Error: %@", err); - } else { - NSLog(@"Remove beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGammaFabric_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [gammaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove gamma fabric: Error: %@", err); - } else { - NSLog(@"Remove gamma fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestTimeSynchronization : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestTimeSynchronization() - : TestCommandBridge("TestTimeSynchronization") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestTimeSynchronization() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestTimeSynchronization\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestTimeSynchronization\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Time Zone\n"); - err = TestReadTimeZone_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Set Time Zone list\n"); - err = TestSetTimeZoneList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Time Zone\n"); - err = TestReadTimeZone_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Set Time Zone with missing optional name field\n"); - err = TestSetTimeZoneWithMissingOptionalNameField_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read Time Zone\n"); - err = TestReadTimeZone_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Set Time Zone with very long name\n"); - err = TestSetTimeZoneWithVeryLongName_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Set Time Zone with first item validAt not zero\n"); - err = TestSetTimeZoneWithFirstItemValidAtNotZero_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Set Time Zone with second item validAt zero\n"); - err = TestSetTimeZoneWithSecondItemValidAtZero_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Set Time Zone with more than supported list count\n"); - err = TestSetTimeZoneWithMoreThanSupportedListCount_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Set Time Zone empty\n"); - err = TestSetTimeZoneEmpty_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read Time Zone\n"); - err = TestReadTimeZone_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read DSTOffset\n"); - err = TestReadDSTOffset_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Set DSTOffset single item\n"); - err = TestSetDSTOffsetSingleItem_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Set DSTOffset empty\n"); - err = TestSetDSTOffsetEmpty_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Set DSTOffset with more than 1 null value\n"); - err = TestSetDSTOffsetWithMoreThan1NullValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Set unsorted DSTOffset entries\n"); - err = TestSetUnsortedDSTOffsetEntries_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Set DSTOffset with multiple entries\n"); - err = TestSetDSTOffsetWithMultipleEntries_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read DSTOffset\n"); - err = TestReadDSTOffset_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Set DSTOffset with same validStarting and validUntil\n"); - err = TestSetDSTOffsetWithSameValidStartingAndValidUntil_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Set DSTOffset with more than supported list count\n"); - err = TestSetDSTOffsetWithMoreThanSupportedListCount_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadTimeZone_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CET"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone list: Error: %@", err); - } else { - NSLog(@"Set Time Zone list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).name, @"CET")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithMissingOptionalNameField_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with missing optional name field: Error: %@", err); - } else { - NSLog(@"Set Time Zone with missing optional name field: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithVeryLongName_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"MunichOnTheLongRiverOfIsarInNiceSummerWeatherWithAugustinerBeerss"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with very long name: Error: %@", err); - } else { - NSLog(@"Set Time Zone with very long name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithFirstItemValidAtNotZero_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CDT"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with first item validAt not zero: Error: %@", err); - } else { - NSLog(@"Set Time Zone with first item validAt not zero: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithSecondItemValidAtZero_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; - - temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with second item validAt zero: Error: %@", err); - } else { - NSLog(@"Set Time Zone with second item validAt zero: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithMoreThanSupportedListCount_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; - - temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; - - temp_0[2] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).validAt = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).name = @"CET"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with more than supported list count: Error: %@", err); - } else { - NSLog(@"Set Time Zone with more than supported list count: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneEmpty_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone empty: Error: %@", err); - } else { - NSLog(@"Set Time Zone empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadDSTOffset_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read DSTOffset: Error: %@", err); - } else { - NSLog(@"Read DSTOffset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetSingleItem_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset single item: Error: %@", err); - } else { - NSLog(@"Set DSTOffset single item: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetEmpty_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset empty: Error: %@", err); - } else { - NSLog(@"Set DSTOffset empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMoreThan1NullValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = nil; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with more than 1 null value: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with more than 1 null value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetUnsortedDSTOffsetEntries_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:3ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set unsorted DSTOffset entries: Error: %@", err); - } else { - NSLog(@"Set unsorted DSTOffset entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMultipleEntries_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with multiple entries: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with multiple entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadDSTOffset_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read DSTOffset: Error: %@", err); - } else { - NSLog(@"Read DSTOffset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).offset, 1L)); - VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validStarting, 1ULL)); - VerifyOrReturn(CheckValueNonNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil)); - VerifyOrReturn(CheckValue("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil, 2ULL)); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validStarting, 3ULL)); - VerifyOrReturn(CheckValueNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validUntil)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithSameValidStartingAndValidUntil_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with same validStarting and validUntil: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with same validStarting and validUntil: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMoreThanSupportedListCount_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = - [NSNumber numberWithUnsignedLongLong:5ULL]; - - temp_0[2] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validStarting = - [NSNumber numberWithUnsignedLongLong:6ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with more than supported list count: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with more than supported list count: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestOperationalState : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestOperationalState() - : TestCommandBridge("TestOperationalState") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestOperationalState() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestOperationalState\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestOperationalState\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); - err = TestReadPhaseList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); - err = TestReadCurrentPhase_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); - err = TestReadCountdownTime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); - err = TestReadOperationalStateList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); - err = TestReadCurrentOperationalError_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); - err = TestStartCommand_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); - err = TestPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); - err = TestResumeCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Stop Command\n"); - err = TestStopCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadPhaseList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Phase List: Error: %@", err); - } else { - NSLog(@"Read Phase List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentPhase_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Phase: Error: %@", err); - } else { - NSLog(@"Read current Phase: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCountdownTime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Countdown Time: Error: %@", err); - } else { - NSLog(@"Read Countdown Time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOperationalStateList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Operational State List: Error: %@", err); - } else { - NSLog(@"Read Operational State List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalError_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalErrorWithCompletion:^(MTROperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational Error: Error: %@", err); - } else { - NSLog(@"Read current Operational Error: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStartCommand_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Start Command: Error: %@", err); - } else { - NSLog(@"Start Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Pause Command: Error: %@", err); - } else { - NSLog(@"Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResumeCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resumeWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Resume Command: Error: %@", err); - } else { - NSLog(@"Resume Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop Command: Error: %@", err); - } else { - NSLog(@"Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestRVCOperationalState : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestRVCOperationalState() - : TestCommandBridge("TestRVCOperationalState") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestRVCOperationalState() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestRVCOperationalState\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestRVCOperationalState\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); - err = TestReadPhaseList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); - err = TestReadCurrentPhase_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); - err = TestReadCountdownTime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); - err = TestReadOperationalStateList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); - err = TestReadCurrentOperationalError_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); - err = TestStartCommand_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); - err = TestPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); - err = TestResumeCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Stop Command\n"); - err = TestStopCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadPhaseList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Phase List: Error: %@", err); - } else { - NSLog(@"Read Phase List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentPhase_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Phase: Error: %@", err); - } else { - NSLog(@"Read current Phase: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCountdownTime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Countdown Time: Error: %@", err); - } else { - NSLog(@"Read Countdown Time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOperationalStateList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Operational State List: Error: %@", err); - } else { - NSLog(@"Read Operational State List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(7))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[4]).operationalStateID, 64U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[5]).operationalStateID, 65U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[6]).operationalStateID, 66U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalError_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalErrorWithCompletion:^(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational Error: Error: %@", err); - } else { - NSLog(@"Read current Operational Error: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStartCommand_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Start Command: Error: %@", err); - } else { - NSLog(@"Start Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Pause Command: Error: %@", err); - } else { - NSLog(@"Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResumeCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resumeWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Resume Command: Error: %@", err); - } else { - NSLog(@"Resume Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop Command: Error: %@", err); - } else { - NSLog(@"Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDishwasherAlarm : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDishwasherAlarm() - : TestCommandBridge("TestDishwasherAlarm") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDishwasherAlarm() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDishwasherAlarm\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDishwasherAlarm\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Supported Attribute\n"); - err = TestReadSupportedAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read State Attribute\n"); - err = TestReadStateAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read feature map Attribute\n"); - err = TestReadFeatureMapAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read State Attribute\n"); - err = TestReadStateAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read State Attribute\n"); - err = TestReadStateAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read State Attribute\n"); - err = TestReadStateAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Reset Command\n"); - err = TestResetCommand_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read State Attribute\n"); - err = TestReadStateAttribute_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadSupportedAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Supported Attribute: Error: %@", err); - } else { - NSLog(@"Read Supported Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Supported", actualValue, 47UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 47UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 7UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFeatureMapAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read feature map Attribute: Error: %@", err); - } else { - NSLog(@"Read feature map Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:41UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:105UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:59UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterResetParams alloc] init]; - params.alarms = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster resetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Command: Error: %@", err); - } else { - NSLog(@"Reset Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestMultiAdmin : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestMultiAdmin() - : TestCommandBridge("TestMultiAdmin") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); - AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); - AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestMultiAdmin() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestMultiAdmin\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestMultiAdmin\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Stop target device\n"); - err = TestStopTargetDevice_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Start target device with the provided discriminator for basic commissioning advertisement\n"); - err = TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Commission from alpha when the commissioning window is not opened\n"); - err = TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from alpha again\n"); - err = TestCommissionFromAlphaAgain_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Check that we just have the one fabric and did not add a new one\n"); - err = TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Close Commissioning Window after failed commissioning\n"); - err = TestCloseCommissioningWindowAfterFailedCommissioning_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Open Commissioning Window from alpha again\n"); - err = TestOpenCommissioningWindowFromAlphaAgain_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Commission from beta\n"); - err = TestCommissionFromBeta_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Open Commissioning Window from beta\n"); - err = TestOpenCommissioningWindowFromBeta_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Commission from gamma\n"); - err = TestCommissionFromGamma_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the commissioned device to be retrieved for gamma\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : read the mandatory attribute: NodeLabel from alpha\n"); - err = TestReadTheMandatoryAttributeNodeLabelFromAlpha_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : write the mandatory attribute NodeLabel from beta\n"); - err = TestWriteTheMandatoryAttributeNodeLabelFromBeta_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : read the mandatory attribute: NodeLabel from gamma\n"); - err = TestReadTheMandatoryAttributeNodeLabelFromGamma_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : write the mandatory attribute NodeLabel back to default\n"); - err = TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mNodeIdForDuplicateCommissioning; - chip::Optional mNodeId2; - chip::Optional mNodeId3; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestStopTargetDevice_0() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; - return Start("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromAlphaAgain_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = false; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that we just have the one fabric and did not add a new one: Error: %@", err); - } else { - NSLog(@"Check that we just have the one fabric and did not add a new one: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseCommissioningWindowAfterFailedCommissioning_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close Commissioning Window after failed commissioning: Error: %@", err); - } else { - NSLog(@"Close Commissioning Window after failed commissioning: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_9() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromBeta_11() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from beta: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromGamma_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("gamma", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - return WaitForCommissionee("gamma", value); - } - NSString * _Nonnull readFromAlpha; - - CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromAlpha_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read the mandatory attribute: NodeLabel from alpha: Error: %@", err); - } else { - NSLog(@"read the mandatory attribute: NodeLabel from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); - } - { - readFromAlpha = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelFromBeta_15() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"written from beta"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"write the mandatory attribute NodeLabel from beta: Error: %@", err); - } else { - NSLog(@"write the mandatory attribute NodeLabel from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromGamma_16() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read the mandatory attribute: NodeLabel from gamma: Error: %@", err); - } else { - NSLog(@"read the mandatory attribute: NodeLabel from gamma: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("nodeLabel", value, readFromAlpha)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = - [readFromAlpha copy]; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"write the mandatory attribute NodeLabel back to default: Error: %@", err); - } else { - NSLog(@"write the mandatory attribute NodeLabel back to default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGSW_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGSW_1_1() - : TestCommandBridge("Test_TC_DGSW_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGSW_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGSW_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGSW_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGSW.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGSW.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList\n"); - if (ShouldSkip("( DGSW.S.F00 || DGSW.S.A0003 )")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("DGSW.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGSW.S.E00 && PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGSW.S.F00")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGSW.S.F00 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSubscribe_OnOff : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSubscribe_OnOff() - : TestCommandBridge("TestSubscribe_OnOff") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSubscribe_OnOff() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_OnOff\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_OnOff\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Set OnOff Attribute to false\n"); - err = TestSetOnOffAttributeToFalse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe OnOff Attribute\n"); - err = TestReportSubscribeOnOffAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe OnOff Attribute\n"); - err = TestSubscribeOnOffAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Check for attribute report\n"); - err = TestCheckForAttributeReport_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check for attribute report\n"); - err = TestCheckForAttributeReport_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSetOnOffAttributeToFalse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set OnOff Attribute to false: Error: %@", err); - } else { - NSLog(@"Set OnOff Attribute to false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_OnOff_OnOff_Reported - = nil; - - CHIP_ERROR TestReportSubscribeOnOffAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe OnOff Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe OnOff Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, false)); - } - - testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeOnOffAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeOnOffWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe OnOff Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe OnOff Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_OnOff_OnOff_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_OnOff_OnOff_Reported; - test_TestSubscribe_OnOff_OnOff_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn On the light to see attribute change: Error: %@", err); - } else { - NSLog(@"Turn On the light to see attribute change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForAttributeReport_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for attribute report: Error: %@", err); - } else { - NSLog(@"Check for attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, true)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off the light to see attribute change: Error: %@", err); - } else { - NSLog(@"Turn Off the light to see attribute change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForAttributeReport_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for attribute report: Error: %@", err); - } else { - NSLog(@"Check for attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, false)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } -}; - -class TestSubscribe_AdministratorCommissioning : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSubscribe_AdministratorCommissioning() - : TestCommandBridge("TestSubscribe_AdministratorCommissioning") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ourVendorId", 0, UINT16_MAX, &mOurVendorId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSubscribe_AdministratorCommissioning() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_AdministratorCommissioning\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_AdministratorCommissioning\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get ourfabric index\n"); - err = TestGetOurfabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe WindowStatus Attribute\n"); - err = TestReportSubscribeWindowStatusAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe WindowStatus Attribute\n"); - err = TestSubscribeWindowStatusAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open the commissioning window 1\n"); - err = TestOpenTheCommissioningWindow1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Check for first attribute report for WindowStatus\n"); - err = TestCheckForFirstAttributeReportForWindowStatus_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Close the commissioning window 1\n"); - err = TestCloseTheCommissioningWindow1_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check for second attribute report for WindowStatus\n"); - err = TestCheckForSecondAttributeReportForWindowStatus_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Report: Subscribe AdminVendorId Attribute\n"); - err = TestReportSubscribeAdminVendorIdAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Subscribe AdminVendorId Attribute\n"); - err = TestSubscribeAdminVendorIdAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Open the commissioning window 2\n"); - err = TestOpenTheCommissioningWindow2_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check for first attribute report for AdminVendorId\n"); - err = TestCheckForFirstAttributeReportForAdminVendorId_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Close the commissioning window 2\n"); - err = TestCloseTheCommissioningWindow2_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Check for second attribute report for AdminVendorId\n"); - err = TestCheckForSecondAttributeReportForAdminVendorId_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Report: Subscribe AdminFabricIndex Attribute\n"); - err = TestReportSubscribeAdminFabricIndexAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Subscribe AdminFabricIndex Attribute\n"); - err = TestSubscribeAdminFabricIndexAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Open the commissioning window 3\n"); - err = TestOpenTheCommissioningWindow3_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check for first attribute report for AdminFabricIndex\n"); - err = TestCheckForFirstAttributeReportForAdminFabricIndex_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Close the commissioning window 2\n"); - err = TestCloseTheCommissioningWindow2_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check for second attribute report for AdminFabricIndex\n"); - err = TestCheckForSecondAttributeReportForAdminFabricIndex_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mOurVendorId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestGetOurfabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get ourfabric index: Error: %@", err); - } else { - NSLog(@"Get ourfabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = nil; - - CHIP_ERROR TestReportSubscribeWindowStatusAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe WindowStatus Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe WindowStatus Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeWindowStatusAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeWindowStatusWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe WindowStatus Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe WindowStatus Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported; - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 1: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForWindowStatus_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for WindowStatus: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for WindowStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow1_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 1: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForWindowStatus_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for WindowStatus: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for WindowStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = nil; - - CHIP_ERROR TestReportSubscribeAdminVendorIdAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe AdminVendorId Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe AdminVendorId Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeAdminVendorIdAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeAdminVendorIdWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe AdminVendorId Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe AdminVendorId Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported; - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow2_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForAdminVendorId_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); - VerifyOrReturn(CheckValue("AdminVendorId", actualValue, mOurVendorId.HasValue() ? mOurVendorId.Value() : 65521U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow2_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForAdminVendorId_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = nil; - - CHIP_ERROR TestReportSubscribeAdminFabricIndexAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeAdminFabricIndexAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeAdminFabricIndexWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe AdminFabricIndex Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe AdminFabricIndex Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported; - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow3_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 3: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForAdminFabricIndex_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (ourFabricIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, ourFabricIndex)); - } - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow2_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForAdminFabricIndex_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } -}; - -class DL_UsersAndCredentials : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - DL_UsersAndCredentials() - : TestCommandBridge("DL_UsersAndCredentials") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~DL_UsersAndCredentials() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: DL_UsersAndCredentials\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: DL_UsersAndCredentials\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read available user slot and verify response fields\n"); - err = TestReadAvailableUserSlotAndVerifyResponseFields_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users and verify default value\n"); - err = TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read fails for user with index 0\n"); - err = TestReadFailsForUserWithIndex0_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read fails for user with index greater than Number Of Users Supported\n"); - err = TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Create new user with default parameters\n"); - err = TestCreateNewUserWithDefaultParameters_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read the user back and verify its fields\n"); - err = TestReadTheUserBackAndVerifyItsFields_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Set user at the occupied index fails with appropriate response\n"); - err = TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Modify userName for existing user\n"); - err = TestModifyUserNameForExistingUser_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Modify userUniqueId for existing user\n"); - err = TestModifyUserUniqueIdForExistingUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Modify userStatus for existing user\n"); - err = TestModifyUserStatusForExistingUser_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Modify userType for existing user\n"); - err = TestModifyUserTypeForExistingUser_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Modify credentialRule for existing user\n"); - err = TestModifyCredentialRuleForExistingUser_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Modify all fields for existing user\n"); - err = TestModifyAllFieldsForExistingUser_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Add another user with non-default fields\n"); - err = TestAddAnotherUserWithNonDefaultFields_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read the new user back and verify its fields\n"); - err = TestReadTheNewUserBackAndVerifyItsFields_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Try to add a user with userStatus 0\n"); - err = TestTryToAddAUserWithUserStatus0_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Make sure the user did not get created\n"); - err = TestMakeSureTheUserDidNotGetCreated_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Try to add a user with userStatus 2\n"); - err = TestTryToAddAUserWithUserStatus2_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Make sure the user did not get created\n"); - err = TestMakeSureTheUserDidNotGetCreated_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Try to add a user with userStatus 3\n"); - err = TestTryToAddAUserWithUserStatus3_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Read the new third user back and verify its fields\n"); - err = TestReadTheNewThirdUserBackAndVerifyItsFields_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Create user in the last slot\n"); - err = TestCreateUserInTheLastSlot_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read the last user back and verify its fields\n"); - err = TestReadTheLastUserBackAndVerifyItsFields_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : User creation in the 0 slot fails\n"); - err = TestUserCreationInThe0SlotFails_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : User creation in the out-of-bounds slot fails\n"); - err = TestUserCreationInTheOutOfBoundsSlotFails_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Clear first user\n"); - err = TestClearFirstUser_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read cleared user and verify it is available\n"); - err = TestReadClearedUserAndVerifyItIsAvailable_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Create new user in the cleared slot\n"); - err = TestCreateNewUserInTheClearedSlot_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read the user in the previously cleared slot and verify its fields\n"); - err = TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Clear user with index 0 fails\n"); - err = TestClearUserWithIndex0Fails_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Clear user with out-of-bounds index fails\n"); - err = TestClearUserWithOutOfBoundsIndexFails_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Clear all users\n"); - err = TestClearAllUsers_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read first cleared user and verify it is available\n"); - err = TestReadFirstClearedUserAndVerifyItIsAvailable_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Read last cleared user and verify it is available\n"); - err = TestReadLastClearedUserAndVerifyItIsAvailable_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Get number of supported PIN credentials and verify default value\n"); - err = TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Check that PIN credential does not exist\n"); - err = TestCheckThatPinCredentialDoesNotExist_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Reading PIN credential with index 0 returns no credential\n"); - err = TestReadingPinCredentialWithIndex0ReturnsNoCredential_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Reading PIN credential with out-of-bounds index returns no credential\n"); - err = TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Verify that a user with UserStatus = 0 cannot be added via SetCredential\n"); - err = TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Verify that a user with UserStatus = 2 cannot be added via SetCredential\n"); - err = TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Create new PIN credential and user\n"); - err = TestCreateNewPinCredentialAndUser_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created user\n"); - err = TestVerifyCreatedUser_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Verify created PIN credential\n"); - err = TestVerifyCreatedPinCredential_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Create new PIN credential and user with index 0 fails\n"); - err = TestCreateNewPinCredentialAndUserWithIndex0Fails_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Create new PIN credential and user with out-of-bounds index fails\n"); - err = TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Get number of supported RFID credentials and verify default value\n"); - err = TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Reading RFID credential with index 0 returns no credential\n"); - err = TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Reading RFID credential with out-of-bounds index returns no credential\n"); - err = TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Check that RFID credential does not exist\n"); - err = TestCheckThatRfidCredentialDoesNotExist_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Create new RFID credential and add it to existing user with non-null UserStatus should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Create new RFID credential and add it to existing user with non-null UserType should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Verify modified user\n"); - err = TestVerifyModifiedUser_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Verify created credential\n"); - err = TestVerifyCreatedCredential_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Create new RFID credential and user with index 0 fails\n"); - err = TestCreateNewRfidCredentialAndUserWithIndex0Fails_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Create new RFID credential and user with out-of-bounds index fails\n"); - err = TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Create new credential and try to add it to 0 user\n"); - err = TestCreateNewCredentialAndTryToAddItTo0User_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Create new credential and try to add it to out-of-bounds user\n"); - err = TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Create new PIN with too short data\n"); - err = TestCreateNewPinWithTooShortData_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Create new PIN with too long data\n"); - err = TestCreateNewPinWithTooLongData_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Create new RFID with too short data\n"); - err = TestCreateNewRfidWithTooShortData_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Create new PIN with Programming user type fails\n"); - err = TestCreateNewPinWithProgrammingUserTypeFails_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Create new RFID with too short data\n"); - err = TestCreateNewRfidWithTooShortData_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Create new PIN credential with data the would cause duplicate\n"); - err = TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Create new RFID credential with data the would cause duplicate\n"); - err = TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Modify credentialData of existing PIN credential with non-null UserStatus should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Modify credentialData of existing PIN credential with non-null UserType should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Modify credentialData of existing PIN credential\n"); - err = TestModifyCredentialDataOfExistingPinCredential_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Verify that credential was changed by creating new credential with old data\n"); - err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Verify that credential was changed by creating new credential with new data\n"); - err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Verify modified user\n"); - err = TestVerifyModifiedUser_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Verify modified user\n"); - err = TestVerifyModifiedUser_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Clear first PIN credential\n"); - err = TestClearFirstPinCredential_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Read back the credential and make sure it is deleted\n"); - err = TestReadBackTheCredentialAndMakeSureItIsDeleted_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Read the user back and make sure PIN credential is deleted\n"); - err = TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Clear the second PIN credential\n"); - err = TestClearTheSecondPinCredential_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Read back the credential and make sure it is deleted\n"); - err = TestReadBackTheCredentialAndMakeSureItIsDeleted_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read the user back and make sure related user is deleted\n"); - err = TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Create new RFID credential with user\n"); - err = TestCreateNewRfidCredentialWithUser_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Clear all the RFID credentials\n"); - err = TestClearAllTheRfidCredentials_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Read back the fist RFID credential and make sure it is deleted\n"); - err = TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Read back the second RFID credential and make sure it is deleted\n"); - err = TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Read back the third RFID credential and make sure it is deleted\n"); - err = TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read the user related with first RFID back and make sure it has only PIN credential\n"); - err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Read the user related with second RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Create new PIN credential with user\n"); - err = TestCreateNewPinCredentialWithUser_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Create new RFID credential with user\n"); - err = TestCreateNewRfidCredentialWithUser_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Create another RFID credential with user\n"); - err = TestCreateAnotherRfidCredentialWithUser_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Clear all the credentials\n"); - err = TestClearAllTheCredentials_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Read back the first PIN credential and make sure it is deleted\n"); - err = TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Read back the first RFID credential and make sure it is deleted\n"); - err = TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read back the second PIN credential and make sure it is deleted\n"); - err = TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Read the user related with first PIN back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Read the user related with first RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Read the user related with second PIN back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read the user related with last RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Create new Programming PIN credential with invalid index\n"); - err = TestCreateNewProgrammingPinCredentialWithInvalidIndex_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Create new Programming PIN credential with valid index\n"); - err = TestCreateNewProgrammingPinCredentialWithValidIndex_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Verify created user\n"); - err = TestVerifyCreatedUser_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Verify created programming PIN credential\n"); - err = TestVerifyCreatedProgrammingPinCredential_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Modify the Programming PIN credential\n"); - err = TestModifyTheProgrammingPinCredential_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Clearing Programming PIN fails\n"); - err = TestClearingProgrammingPinFails_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Clearing Programming PIN with invalid index fails\n"); - err = TestClearingProgrammingPinWithInvalidIndexFails_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Clearing PIN credential with zero index fails\n"); - err = TestClearingPinCredentialWithZeroIndexFails_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Clearing PIN credential with out-of-bound index fails\n"); - err = TestClearingPinCredentialWithOutOfBoundIndexFails_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Clearing RFID credential with zero index fails\n"); - err = TestClearingRfidCredentialWithZeroIndexFails_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Clearing RFID credential with out-of-bound index fails\n"); - err = TestClearingRfidCredentialWithOutOfBoundIndexFails_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Clear the Programming PIN user\n"); - err = TestClearTheProgrammingPinUser_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure Programming PIN user is deleted\n"); - err = TestMakeSureProgrammingPinUserIsDeleted_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Make sure programming PIN credential is deleted\n"); - err = TestMakeSureProgrammingPinCredentialIsDeleted_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Create new PIN credential and user\n"); - err = TestCreateNewPinCredentialAndUser_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Create second PIN credential and add it to existing user\n"); - err = TestCreateSecondPinCredentialAndAddItToExistingUser_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Create third PIN credential and add it to existing user\n"); - err = TestCreateThirdPinCredentialAndAddItToExistingUser_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Create fourth PIN credential and add it to existing user\n"); - err = TestCreateFourthPinCredentialAndAddItToExistingUser_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Create fifth PIN credential and add it to existing user\n"); - err = TestCreateFifthPinCredentialAndAddItToExistingUser_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Try to create sixth PIN credential and make sure it fails\n"); - err = TestTryToCreateSixthPinCredentialAndMakeSureItFails_126(); - break; - case 127: - ChipLogProgress(chipTool, " ***** Test Step 127 : Final clean-up\n"); - err = TestFinalCleanUp_127(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 127: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 128; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAvailableUserSlotAndVerifyResponseFields_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read available user slot and verify response fields: Error: %@", err); - } else { - NSLog(@"Read available user slot and verify response fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported users and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported users and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); - } - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFailsForUserWithIndex0_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fails for user with index 0: Error: %@", err); - } else { - NSLog(@"Read fails for user with index 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fails for user with index greater than Number Of Users Supported: Error: %@", err); - } else { - NSLog(@"Read fails for user with index greater than Number Of Users Supported: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserWithDefaultParameters_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user with default parameters: Error: %@", err); - } else { - NSLog(@"Create new user with default parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set user at the occupied index fails with appropriate response: Error: %@", err); - } else { - NSLog(@"Set user at the occupied index fails with appropriate response: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserNameForExistingUser_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"new_user"; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userName for existing user: Error: %@", err); - } else { - NSLog(@"Modify userName for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserUniqueIdForExistingUser_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:305441741UL]; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userUniqueId for existing user: Error: %@", err); - } else { - NSLog(@"Modify userUniqueId for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserStatusForExistingUser_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:3U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userStatus for existing user: Error: %@", err); - } else { - NSLog(@"Modify userStatus for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserTypeForExistingUser_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:6U]; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userType for existing user: Error: %@", err); - } else { - NSLog(@"Modify userType for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialRuleForExistingUser_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = - [NSNumber numberWithUnsignedChar:2U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialRule for existing user: Error: %@", err); - } else { - NSLog(@"Modify credentialRule for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyAllFieldsForExistingUser_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"test_user"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:466460832UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify all fields for existing user: Error: %@", err); - } else { - NSLog(@"Modify all fields for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 466460832UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 1U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddAnotherUserWithNonDefaultFields_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = @"test_user2"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:12648430UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:1U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:2U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add another user with non-default fields: Error: %@", err); - } else { - NSLog(@"Add another user with non-default fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheNewUserBackAndVerifyItsFields_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the new user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the new user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user2")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 12648430UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 1U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus0_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:0U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 0: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure the user did not get created: Error: %@", err); - } else { - NSLog(@"Make sure the user did not get created: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus2_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:2U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 2: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure the user did not get created: Error: %@", err); - } else { - NSLog(@"Make sure the user did not get created: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus3_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:3U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 3: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheNewThirdUserBackAndVerifyItsFields_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the new third user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the new third user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user3")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 47802UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateUserInTheLastSlot_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - params.userName = @"last_user"; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create user in the last slot: Error: %@", err); - } else { - NSLog(@"Create user in the last slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheLastUserBackAndVerifyItsFields_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the last user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the last user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"last_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestUserCreationInThe0SlotFails_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"User creation in the 0 slot fails: Error: %@", err); - } else { - NSLog(@"User creation in the 0 slot fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestUserCreationInTheOutOfBoundsSlotFails_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"User creation in the out-of-bounds slot fails: Error: %@", err); - } else { - NSLog(@"User creation in the out-of-bounds slot fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearFirstUser_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear first user: Error: %@", err); - } else { - NSLog(@"Clear first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadClearedUserAndVerifyItIsAvailable_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserInTheClearedSlot_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user in the cleared slot: Error: %@", err); - } else { - NSLog(@"Create new user in the cleared slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user in the previously cleared slot and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user in the previously cleared slot and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserWithIndex0Fails_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Clear user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserWithOutOfBoundsIndexFails_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Clear user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllUsers_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all users: Error: %@", err); - } else { - NSLog(@"Clear all users: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFirstClearedUserAndVerifyItIsAvailable_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read first cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read first cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLastClearedUserAndVerifyItIsAvailable_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read last cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read last cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfPINUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfPINUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported PIN credentials and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported PIN credentials and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfPINUsersSupported", actualValue, 10U)); - } - { - NumberOfPINUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatPinCredentialDoesNotExist_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that PIN credential does not exist: Error: %@", err); - } else { - NSLog(@"Check that PIN credential does not exist: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingPinCredentialWithIndex0ReturnsNoCredential_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading PIN credential with index 0 returns no credential: Error: %@", err); - } else { - NSLog(@"Reading PIN credential with index 0 returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Error: %@", err); - } else { - NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:0U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Error: %@", err); - } else { - NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:2U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Error: %@", err); - } else { - NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUser_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedUser_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created user: Error: %@", err); - } else { - NSLog(@"Verify created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedPinCredential_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUserWithIndex0Fails_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfRFIDUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRFIDUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported RFID credentials and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported RFID credentials and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfRFIDUsersSupported", actualValue, 10U)); - } - { - NumberOfRFIDUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading RFID credential with index 0 returns no credential: Error: %@", err); - } else { - NSLog(@"Reading RFID credential with index 0 returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Error: %@", err); - } else { - NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatRfidCredentialDoesNotExist_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that RFID credential does not exist: Error: %@", err); - } else { - NSLog(@"Check that RFID credential does not exist: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedCredential_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created credential: Error: %@", err); - } else { - NSLog(@"Verify created credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndUserWithIndex0Fails_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewCredentialAndTryToAddItTo0User_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123465" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new credential and try to add it to 0 user: Error: %@", err); - } else { - NSLog(@"Create new credential and try to add it to 0 user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123465" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new credential and try to add it to out-of-bounds user: Error: %@", err); - } else { - NSLog(@"Create new credential and try to add it to out-of-bounds user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithTooShortData_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"12345" length:5]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with too short data: Error: %@", err); - } else { - NSLog(@"Create new PIN with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithTooLongData_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456789" length:9]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with too long data: Error: %@", err); - } else { - NSLog(@"Create new PIN with too long data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidWithTooShortData_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data" length:9]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID with too short data: Error: %@", err); - } else { - NSLog(@"Create new RFID with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithProgrammingUserTypeFails_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with Programming user type fails: Error: %@", err); - } else { - NSLog(@"Create new PIN with Programming user type fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidWithTooShortData_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"very_long_rfid_data_to_test_boundaries" length:38]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID with too short data: Error: %@", err); - } else { - NSLog(@"Create new RFID with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential with data the would cause duplicate: Error: %@", err); - } else { - NSLog(@"Create new PIN credential with data the would cause duplicate: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with data the would cause duplicate: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with data the would cause duplicate: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredential_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that credential was changed by creating new credential with old data: Error: %@", err); - } else { - NSLog(@"Verify that credential was changed by creating new credential with old data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that credential was changed by creating new credential with new data: Error: %@", err); - } else { - NSLog(@"Verify that credential was changed by creating new credential with new data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_7890" length:14]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"789012" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearFirstPinCredential_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear first PIN credential: Error: %@", err); - } else { - NSLog(@"Clear first PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and make sure PIN credential is deleted: Error: %@", err); - } else { - NSLog(@"Read the user back and make sure PIN credential is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 2U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearTheSecondPinCredential_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear the second PIN credential: Error: %@", err); - } else { - NSLog(@"Clear the second PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and make sure related user is deleted: Error: %@", err); - } else { - NSLog(@"Read the user back and make sure related user is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithUser_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_12345" length:15]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllTheRfidCredentials_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:65534U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all the RFID credentials: Error: %@", err); - } else { - NSLog(@"Clear all the RFID credentials: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the fist RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the fist RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the second RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the second RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the third RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the third RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Error: %@", err); - } else { - NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with second RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with second RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialWithUser_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential with user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithUser_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_1234" length:14]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherRfidCredentialWithUser_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_9876" length:14]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create another RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllTheCredentials_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = nil; - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all the credentials: Error: %@", err); - } else { - NSLog(@"Clear all the credentials: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the first PIN credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the first PIN credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the first RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the first RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the second PIN credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the second PIN credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first PIN back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with first PIN back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with first RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with second PIN back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with second PIN back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:4U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with last RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with last RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewProgrammingPinCredentialWithInvalidIndex_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new Programming PIN credential with invalid index: Error: %@", err); - } else { - NSLog(@"Create new Programming PIN credential with invalid index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewProgrammingPinCredentialWithValidIndex_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new Programming PIN credential with valid index: Error: %@", err); - } else { - NSLog(@"Create new Programming PIN credential with valid index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedUser_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created user: Error: %@", err); - } else { - NSLog(@"Verify created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 0U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 0U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedProgrammingPinCredential_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created programming PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created programming PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyTheProgrammingPinCredential_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"654321" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify the Programming PIN credential: Error: %@", err); - } else { - NSLog(@"Modify the Programming PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingProgrammingPinFails_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing Programming PIN fails: Error: %@", err); - } else { - NSLog(@"Clearing Programming PIN fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingProgrammingPinWithInvalidIndexFails_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing Programming PIN with invalid index fails: Error: %@", err); - } else { - NSLog(@"Clearing Programming PIN with invalid index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingPinCredentialWithZeroIndexFails_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing PIN credential with zero index fails: Error: %@", err); - } else { - NSLog(@"Clearing PIN credential with zero index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingPinCredentialWithOutOfBoundIndexFails_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing PIN credential with out-of-bound index fails: Error: %@", err); - } else { - NSLog(@"Clearing PIN credential with out-of-bound index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingRfidCredentialWithZeroIndexFails_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing RFID credential with zero index fails: Error: %@", err); - } else { - NSLog(@"Clearing RFID credential with zero index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingRfidCredentialWithOutOfBoundIndexFails_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing RFID credential with out-of-bound index fails: Error: %@", err); - } else { - NSLog(@"Clearing RFID credential with out-of-bound index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearTheProgrammingPinUser_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear the Programming PIN user: Error: %@", err); - } else { - NSLog(@"Clear the Programming PIN user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureProgrammingPinUserIsDeleted_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure Programming PIN user is deleted: Error: %@", err); - } else { - NSLog(@"Make sure Programming PIN user is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureProgrammingPinCredentialIsDeleted_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure programming PIN credential is deleted: Error: %@", err); - } else { - NSLog(@"Make sure programming PIN credential is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUser_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateSecondPinCredentialAndAddItToExistingUser_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000001" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create second PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create second PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateThirdPinCredentialAndAddItToExistingUser_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000002" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create third PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create third PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateFourthPinCredentialAndAddItToExistingUser_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:4U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000003" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create fourth PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create fourth PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateFifthPinCredentialAndAddItToExistingUser_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:5U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000004" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create fifth PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create fifth PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToCreateSixthPinCredentialAndMakeSureItFails_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000005" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to create sixth PIN credential and make sure it fails: Error: %@", err); - } else { - NSLog(@"Try to create sixth PIN credential and make sure it fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 137U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestFinalCleanUp_127() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Final clean-up: Error: %@", err); - } else { - NSLog(@"Final clean-up: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class DL_Schedules : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - DL_Schedules() - : TestCommandBridge("DL_Schedules") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~DL_Schedules() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: DL_Schedules\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: DL_Schedules\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Create new PIN credential and schedule user\n"); - err = TestCreateNewPinCredentialAndScheduleUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users\n"); - err = TestGetNumberOfSupportedUsers_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Get Max number of Week Day schedules for user and verify default value\n"); - err = TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Get Max number of Year Day schedules for user and verify default value\n"); - err = TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Get Max number of Holiday schedules and verify default value\n"); - err = TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Create Week Day schedule with 0 index\n"); - err = TestCreateWeekDayScheduleWith0Index_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Create Week Day schedule with out-of-bounds index\n"); - err = TestCreateWeekDayScheduleWithOutOfBoundsIndex_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Create Week Day schedule with 0 user index\n"); - err = TestCreateWeekDayScheduleWith0UserIndex_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Create Week Day schedule with out-of-bounds user index\n"); - err = TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Create Week Day schedule for non-existing user\n"); - err = TestCreateWeekDayScheduleForNonExistingUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Create Week Day schedule with 0 days mask\n"); - err = TestCreateWeekDayScheduleWith0DaysMask_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Create Week Day schedule for Sunday and Monday\n"); - err = TestCreateWeekDayScheduleForSundayAndMonday_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Create Week Day schedule for Sunday Wednesday and Saturday\n"); - err = TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Create Week Day schedule with invalid start hour\n"); - err = TestCreateWeekDayScheduleWithInvalidStartHour_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Create Week Day schedule with invalid start minute\n"); - err = TestCreateWeekDayScheduleWithInvalidStartMinute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Create Week Day schedule with invalid end hour\n"); - err = TestCreateWeekDayScheduleWithInvalidEndHour_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Create Week Day schedule with invalid end minute\n"); - err = TestCreateWeekDayScheduleWithInvalidEndMinute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Create Week Day schedule with start hour later that end hour\n"); - err = TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Create Week Day schedule with start minute later that end minute when hours are equal\n"); - err = TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Get Week Day schedule with 0 index\n"); - err = TestGetWeekDayScheduleWith0Index_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Get Week Day schedule with out-of-bounds index\n"); - err = TestGetWeekDayScheduleWithOutOfBoundsIndex_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Get Week Day schedule with 0 user index\n"); - err = TestGetWeekDayScheduleWith0UserIndex_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Get Week Day schedule with out-of-bounds user index\n"); - err = TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Get Week Day schedule with non-existing user index\n"); - err = TestGetWeekDayScheduleWithNonExistingUserIndex_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Create Year Day schedule with 0 index\n"); - err = TestCreateYearDayScheduleWith0Index_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Create Year Day schedule with out-of-bounds index\n"); - err = TestCreateYearDayScheduleWithOutOfBoundsIndex_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Create Year Day schedule with 0 user index\n"); - err = TestCreateYearDayScheduleWith0UserIndex_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Create Year Day schedule with out-of-bounds user index\n"); - err = TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Create Year Day schedule for non-existing user\n"); - err = TestCreateYearDayScheduleForNonExistingUser_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Create Year Day schedule with start hour later that end hour\n"); - err = TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Get Year Day schedule with 0 index\n"); - err = TestGetYearDayScheduleWith0Index_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Get Year Day schedule with out-of-bounds index\n"); - err = TestGetYearDayScheduleWithOutOfBoundsIndex_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Get Year Day schedule with 0 user index\n"); - err = TestGetYearDayScheduleWith0UserIndex_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Get Year Day schedule with out-of-bounds user index\n"); - err = TestGetYearDayScheduleWithOutOfBoundsUserIndex_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Get Year Day schedule with non-existing user index\n"); - err = TestGetYearDayScheduleWithNonExistingUserIndex_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Create Holiday schedule with 0 index\n"); - err = TestCreateHolidayScheduleWith0Index_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Create Holiday schedule with out-of-bounds index\n"); - err = TestCreateHolidayScheduleWithOutOfBoundsIndex_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Create Holiday schedule with start hour later that end hour\n"); - err = TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Create Holiday schedule with invalid operating mode\n"); - err = TestCreateHolidayScheduleWithInvalidOperatingMode_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Get Holiday schedule with 0 index\n"); - err = TestGetHolidayScheduleWith0Index_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Get Holiday schedule with out-of-bounds index\n"); - err = TestGetHolidayScheduleWithOutOfBoundsIndex_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Create Holiday schedule with valid parameters\n"); - err = TestCreateHolidayScheduleWithValidParameters_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Create Week Day schedule with valid parameters\n"); - err = TestCreateWeekDayScheduleWithValidParameters_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Create Year Day schedule with valid parameters\n"); - err = TestCreateYearDayScheduleWithValidParameters_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Clear Week Day schedule with 0 index\n"); - err = TestClearWeekDayScheduleWith0Index_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Clear Week Day schedule with out-of-bounds index\n"); - err = TestClearWeekDayScheduleWithOutOfBoundsIndex_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Clear Week Day schedule with 0 user index\n"); - err = TestClearWeekDayScheduleWith0UserIndex_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Clear Week Day schedule with out-of-bounds user index\n"); - err = TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Clear Week Day schedule with non-existing user\n"); - err = TestClearWeekDayScheduleWithNonExistingUser_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Clear Year Day schedule with 0 index\n"); - err = TestClearYearDayScheduleWith0Index_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Clear Year Day schedule with out-of-bounds index\n"); - err = TestClearYearDayScheduleWithOutOfBoundsIndex_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Clear Year Day schedule with 0 user index\n"); - err = TestClearYearDayScheduleWith0UserIndex_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Clear Year Day schedule with out-of-bounds user index\n"); - err = TestClearYearDayScheduleWithOutOfBoundsUserIndex_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Clear Year Day schedule with non-existing user\n"); - err = TestClearYearDayScheduleWithNonExistingUser_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Clear Holiday schedule with 0 index\n"); - err = TestClearHolidayScheduleWith0Index_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Clear Holiday schedule with out-of-bounds index\n"); - err = TestClearHolidayScheduleWithOutOfBoundsIndex_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Create another Week Day schedule with valid parameters\n"); - err = TestCreateAnotherWeekDayScheduleWithValidParameters_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Verify created week day schedule\n"); - err = TestVerifyCreatedWeekDaySchedule_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Create another Year Day schedule with valid parameters\n"); - err = TestCreateAnotherYearDayScheduleWithValidParameters_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Verify created year day schedule\n"); - err = TestVerifyCreatedYearDaySchedule_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Create another Holiday schedule with valid parameters\n"); - err = TestCreateAnotherHolidayScheduleWithValidParameters_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Verify created holiday schedule\n"); - err = TestVerifyCreatedHolidaySchedule_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Clear a single week day schedule for the first user\n"); - err = TestClearASingleWeekDayScheduleForTheFirstUser_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Verify cleared week day schedule\n"); - err = TestVerifyClearedWeekDaySchedule_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Clear all remaining week day schedules for the first user\n"); - err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Verify cleared week schedule\n"); - err = TestVerifyClearedWeekSchedule_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Make sure that first year day schedule was not deleted\n"); - err = TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Make sure that second year day schedule was not deleted\n"); - err = TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Make sure that second holiday schedule was not deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Create another Week Day schedule with valid parameters\n"); - err = TestCreateAnotherWeekDayScheduleWithValidParameters_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Clear a single year day schedule for the first user\n"); - err = TestClearASingleYearDayScheduleForTheFirstUser_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Verify cleared year day schedule\n"); - err = TestVerifyClearedYearDaySchedule_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Clear all remaining year schedules for the first user\n"); - err = TestClearAllRemainingYearSchedulesForTheFirstUser_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Verify that second year day schedule was cleared\n"); - err = TestVerifyThatSecondYearDayScheduleWasCleared_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Verify created week day schedule\n"); - err = TestVerifyCreatedWeekDaySchedule_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Clear all remaining week day schedules for the first user\n"); - err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Create new user without credential so we can add more schedules to it\n"); - err = TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Create Week Day schedule with valid parameters for first user\n"); - err = TestCreateWeekDayScheduleWithValidParametersForFirstUser_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Verify created week day schedule for first user\n"); - err = TestVerifyCreatedWeekDayScheduleForFirstUser_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Create Year Day schedule for first user\n"); - err = TestCreateYearDayScheduleForFirstUser_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Verify created year day schedule for first\n"); - err = TestVerifyCreatedYearDayScheduleForFirst_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Create Week Day schedule with valid parameters for second user\n"); - err = TestCreateWeekDayScheduleWithValidParametersForSecondUser_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Verify created week day schedule for first user\n"); - err = TestVerifyCreatedWeekDayScheduleForFirstUser_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Create Year Day schedule for second user\n"); - err = TestCreateYearDayScheduleForSecondUser_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Verify created year day schedule for first\n"); - err = TestVerifyCreatedYearDayScheduleForFirst_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Cleanup the user\n"); - err = TestCleanupTheUser_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Make sure clearing first user also cleared week day schedules\n"); - err = TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Make sure clearing first user also cleared year day schedules\n"); - err = TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Make sure clearing second user also cleared week day schedules\n"); - err = TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Make sure clearing second user also cleared year day schedules\n"); - err = TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Make sure that second holiday schedule was not deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Create another Holiday schedule at the last slot\n"); - err = TestCreateAnotherHolidayScheduleAtTheLastSlot_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Verify Created Holiday Schedule\n"); - err = TestVerifyCreatedHolidaySchedule_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Create new PIN credential and schedule user\n"); - err = TestCreateNewPinCredentialAndScheduleUser_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Create Week Day schedule for first user\n"); - err = TestCreateWeekDayScheduleForFirstUser_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Create Year Day schedule for first user\n"); - err = TestCreateYearDayScheduleForFirstUser_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Clear a single holiday schedule\n"); - err = TestClearASingleHolidaySchedule_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Make sure that second holiday schedule was deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasDeleted_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Make sure that third holiday schedule was not deleted\n"); - err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Make sure clearing holiday schedule did not clear week day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure clearing holiday schedule did not clear year day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Clear all remaining holiday schedules\n"); - err = TestClearAllRemainingHolidaySchedules_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Make sure that first holiday is still deleted\n"); - err = TestMakeSureThatFirstHolidayIsStillDeleted_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Make sure that second holiday schedule was deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasDeleted_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Make sure that third holiday schedule was not deleted\n"); - err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Make sure clearing holiday schedule did not clear week day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Make sure clearing holiday schedule did not clear year day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Final Cleanup\n"); - err = TestFinalCleanup_126(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 127; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and schedule user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and schedule user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedUsers_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported users: Error: %@", err); - } else { - NSLog(@"Get number of supported users: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); - } - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Week Day schedules for user and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Week Day schedules for user and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfWeekDaySchedulesSupportedPerUser", actualValue, 10U)); - } - { - NumberOfWeekDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Year Day schedules for user and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Year Day schedules for user and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfYearDaySchedulesSupportedPerUser", actualValue, 10U)); - } - { - NumberOfYearDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; - - CHIP_ERROR TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Holiday schedules and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Holiday schedules and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfHolidaySchedulesSupported", actualValue, 10U)); - } - { - NumberOfHolidaySchedulesSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0Index_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsIndex_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0UserIndex_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForNonExistingUser_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for non-existing user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0DaysMask_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:0U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 days mask: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 days mask: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForSundayAndMonday_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:3U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for Sunday and Monday: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for Sunday and Monday: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:73U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartHour_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:24U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid start hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid start hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartMinute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:60U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid start minute: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid start minute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndHour_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:24U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid end hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndMinute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:60U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid end minute: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid end minute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:19U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:50U]; - params.endHour = - [NSNumber numberWithUnsignedChar:15U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:49U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWith0Index_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsIndex_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, [NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWith0UserIndex_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithNonExistingUserIndex_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with non-existing user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with non-existing user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWith0Index_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsIndex_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWith0UserIndex_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForNonExistingUser_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for non-existing user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345688UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWith0Index_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsIndex_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, [NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWith0UserIndex_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsUserIndex_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithNonExistingUserIndex_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with non-existing user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with non-existing user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWith0Index_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithOutOfBoundsIndex_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345688UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithInvalidOperatingMode_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:5U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with invalid operating mode: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with invalid operating mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetHolidayScheduleWith0Index_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetHolidayScheduleWithOutOfBoundsIndex_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, [NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithValidParameters_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParameters_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithValidParameters_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWith0Index_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsIndex_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWith0UserIndex_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithNonExistingUser_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with non-existing user: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWith0Index_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsIndex_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWith0UserIndex_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsUserIndex_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithNonExistingUser_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with non-existing user: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearHolidayScheduleWith0Index_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearHolidayScheduleWithOutOfBoundsIndex_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDaySchedule_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherYearDayScheduleWithValidParameters_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Year Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Year Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDaySchedule_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherHolidayScheduleWithValidParameters_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:123456UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:1234567UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Holiday schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Holiday schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedHolidaySchedule_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created holiday schedule: Error: %@", err); - } else { - NSLog(@"Verify created holiday schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleWeekDayScheduleForTheFirstUser_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single week day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a single week day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedWeekDaySchedule_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared week day schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining week day schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedWeekSchedule_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared week schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared week schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleYearDayScheduleForTheFirstUser_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single year day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a single year day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedYearDaySchedule_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared year day schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingYearSchedulesForTheFirstUser_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining year schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining year schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSecondYearDayScheduleWasCleared_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that second year day schedule was cleared: Error: %@", err); - } else { - NSLog(@"Verify that second year day schedule was cleared: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDaySchedule_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining week day schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user without credential so we can add more schedules to it: Error: %@", err); - } else { - NSLog(@"Create new user without credential so we can add more schedules to it: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForFirstUser_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters for first user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule for first user: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForFirstUser_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule for first: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule for first: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForSecondUser_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:64U]; - params.startHour = - [NSNumber numberWithUnsignedChar:23U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters for second user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters for second user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule for first user: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 64U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 23U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForSecondUser_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:55555UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:7777777UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for second user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for second user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule for first: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule for first: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 55555UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 7777777UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheUser_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the user: Error: %@", err); - } else { - NSLog(@"Cleanup the user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing first user also cleared week day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing first user also cleared week day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing first user also cleared year day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing first user also cleared year day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing second user also cleared week day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing second user also cleared week day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing second user also cleared year day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing second user also cleared year day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherHolidayScheduleAtTheLastSlot_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:100UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:4U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Holiday schedule at the last slot: Error: %@", err); - } else { - NSLog(@"Create another Holiday schedule at the last slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedHolidaySchedule_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Created Holiday Schedule: Error: %@", err); - } else { - NSLog(@"Verify Created Holiday Schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and schedule user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and schedule user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForFirstUser_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForFirstUser_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleHolidaySchedule_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single holiday schedule: Error: %@", err); - } else { - NSLog(@"Clear a single holiday schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that third holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingHolidaySchedules_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:254U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining holiday schedules: Error: %@", err); - } else { - NSLog(@"Clear all remaining holiday schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayIsStillDeleted_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday is still deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday is still deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that third holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestFinalCleanup_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Final Cleanup: Error: %@", err); - } else { - NSLog(@"Final Cleanup: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_1_1() - : TestCommandBridge("Test_TC_DRLK_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DRLK.S.F00 && !DRLK.S.F01 && !DRLK.S.F02 && !DRLK.S.F04 && !DRLK.S.F05 && !DRLK.S.F06 && !DRLK.S.F07 && !DRLK.S.F08 && !DRLK.S.F0a && !DRLK.S.F0b && !DRLK.S.F0c ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F05")) { - NextTest(); - return; - } - err = TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F06")) { - NextTest(); - return; - } - err = TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F07")) { - NextTest(); - return; - } - err = TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0c")) { - NextTest(); - return; - } - err = TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F05")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F00 || DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F07 || DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4k: TH reads optional attribute(Language) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0021")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4l: TH reads optional attribute(LEDSettings) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0022")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0023")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4n: TH reads optional attribute(SoundVolume) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0024")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0027")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0028")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0029")) { - NextTest(); - return; - } - err = TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002a")) { - NextTest(); - return; - } - err = TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002b")) { - NextTest(); - return; - } - err = TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002c")) { - NextTest(); - return; - } - err = TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5b: TH reads optional event(Door position sensor) in EventList\n"); - if (ShouldSkip("DRLK.S.F05 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5c: TH reads optional event(User commands and database) in EventList\n"); - if (ShouldSkip("DRLK.S.F08 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6a: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6aThReadsAcceptedCommandListFromDut_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0c")) { - NextTest(); - return; - } - err = TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 49; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 7U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 39UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 29UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 34UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 36UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 38UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 35UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_4() - : TestCommandBridge("Test_TC_DRLK_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Create new user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read the user back and verify its fields\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Create new PIN credential and lock/unlock user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCreateNewPinCredentialAndLockUnlockUser_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify created PIN credential\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestVerifyCreatedPinCredential_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { - NextTest(); - return; - } - err = TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { - NextTest(); - return; - } - err = TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); - if (ShouldSkip(" DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { - NextTest(); - return; - } - err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); - if (ShouldSkip(" (!DRLK.S.F08 || !DRLK.S.F00) && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { - NextTest(); - return; - } - err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2c: TH reads LockState attribute\n"); - if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsLockStateAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Cleanup the created user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCleanupTheCreatedUser_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Clean the created credential\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestCleanTheCreatedCredential_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user: Error: %@", err); - } else { - NSLog(@"Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and lock/unlock user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and lock/unlock user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedPinCredential_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:10U]; - params.pinCode = - [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:60U]; - params.pinCode = - [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:60U]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitForAutoRelockTimeExpires_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 11000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForAutoRelockTimeExpires_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 70000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsLockStateAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads LockState attribute: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads LockState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); - VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanTheCreatedCredential_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clean the created credential: Error: %@", err); - } else { - NSLog(@"Clean the created credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_5() - : TestCommandBridge("Test_TC_DRLK_2_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.A0014")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55 \n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs1BUserIndexAs1CDaysMaskMapAs2DStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH send Get Week Day Schedule Command to DUT with a)WeekDayIndex as 1 b)UserIndex as 1 \n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep4ThSendGetWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs0InvalidValueBUserIndexAs1CDaysMaskMapAs7InvalidValueDStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex as 0 b)UserIndex as 1 \n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendGetWeekDayScheduleCommandToDutAWeekDayIndexAs0BUserIndexAs1_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User)\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep7ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 8: TH sends Clear Week Day Schedule Command to DUT with : a)WeekDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0d.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsClearWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 9: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep9ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1BUserIndexAs1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfWeekDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs1BUserIndexAs1CDaysMaskMapAs2DStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:45U]; - params.endHour = - [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55 : Error: %@", err); - } else { - NSLog(@"Step 3: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55 : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendGetWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT with a)WeekDayIndex as 1 b)UserIndex as 1 : Error: %@", err); - } else { - NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT with a)WeekDayIndex as 1 b)UserIndex as 1 : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 45U)); - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, true)); - if (values.endHour != nil) { - - VerifyOrReturn(CheckConstraintMinValue("endHour", [values.endHour unsignedCharValue], 16U)); - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, true)); - if (values.endMinute != nil) { - - VerifyOrReturn(CheckConstraintMinValue("endMinute", [values.endMinute unsignedCharValue], 55U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendSetWeekDayScheduleCommandToDutWithTheFollowingValuesAWeekDayIndexAs0InvalidValueBUserIndexAs1CDaysMaskMapAs7InvalidValueDStartHourAs15EStartMinuteAs45FEndHourAs16GEndMinuteAs55_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:7U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:45U]; - params.endHour = - [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55: Error: %@", err); - } else { - NSLog(@"Step 5: TH send Set Week Day Schedule Command to DUT with the following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute as 55: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendGetWeekDayScheduleCommandToDutAWeekDayIndexAs0BUserIndexAs1_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex as 0 b)UserIndex as 1 : Error: %@", err); - } else { - NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex as 0 b)UserIndex as 1 : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Error: %@", err); - } else { - NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsClearWeekDayScheduleCommandToDutWithAWeekDayIndexAs1BUserIndexAs1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT with : a)WeekDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT with : a)WeekDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsGetWeekDayScheduleCommandToDutWithFollowingValuesAWeekDayIndexAs1BUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT with following values: a)WeekDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_6() - : TestCommandBridge("Test_TC_DRLK_2_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); - err = TestWaitForCommissionee_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.A0016")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value)\n"); - if (ShouldSkip("DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available)\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C13.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForCommissionee_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; - - CHIP_ERROR TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 255U)); - { - NumberOfHolidaySchedulesSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 20UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 30UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 21UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:5U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Error: %@", err); - } else { - NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:15U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:10U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Error: %@", err); - } else { - NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 10U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_7() - : TestCommandBridge("Test_TC_DRLK_2_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.A0015")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 960 Seconds d)LocalEndTime as 1980 Seconds\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs960SecondsDLocalEndTimeAs1980Seconds_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep4a4bThSendsGetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 0(Invalid value) b)UserIndex as 15(Invalid value) c)LocalStartTime as 1020 d)LocalEndTime as 2040\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs0InvalidValueBUserIndexAs15InvalidValueCLocalStartTimeAs1020DLocalEndTimeAs2040_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 0 b)UserIndex as 15\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs0BUserIndexAs15_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7a: Create a new user with UserIndex as 5 then TH sends Get Year Day Schedule Command to DUT with\n"); - err = TestStep7aCreateANewUserWithUserIndexAs5ThenThSendsGetYearDayScheduleCommandToDutWith_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7b: YearDayIndex as 10 (value is in the the range of step 1 but YearDay Schedule entry not available) : UserIndex as 5\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep7bYearDayIndexAs10ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableUserIndexAs5_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 1 b)UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs1BUserIndexAs1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 9: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (value is in the the range of step 1 but YearDay Schedule entry not available) b)UserDayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableBUserDayIndexAs1_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 10: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 1080 Seconds d)LocalEndTime as 2100 Seconds\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs1080SecondsDLocalEndTimeAs2100Seconds_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 11: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 1 b)UserDayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep11ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1BUserDayIndexAs1_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 12: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User)\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep12ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 13: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 0(Invalid value) b)UserIndex as 0 (Invalid value)\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs0InvalidValueBUserIndexAs0InvalidValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Clear a year day schedule for the first user\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestClearAYearDayScheduleForTheFirstUser_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Cleanup the created user with UserIndex 1\n"); - err = TestCleanupTheCreatedUserWithUserIndex1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Cleanup the created user with UserIndex 5\n"); - err = TestCleanupTheCreatedUserWithUserIndex5_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttributeAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfYearDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for future use: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs960SecondsDLocalEndTimeAs1980Seconds_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:960UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:1980UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 960 Seconds d)LocalEndTime as 1980 Seconds: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 960 Seconds d)LocalEndTime as 1980 Seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a4bThSendsGetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 960UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1980UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 961UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs0InvalidValueBUserIndexAs15InvalidValueCLocalStartTimeAs1020DLocalEndTimeAs2040_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:15U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1020UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:2040UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 0(Invalid value) b)UserIndex as 15(Invalid value) c)LocalStartTime as 1020 d)LocalEndTime as 2040: Error: %@", err); - } else { - NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 0(Invalid value) b)UserIndex as 15(Invalid value) c)LocalStartTime as 1020 d)LocalEndTime as 2040: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs0BUserIndexAs15_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:15U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 0 b)UserIndex as 15: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 0 b)UserIndex as 15: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aCreateANewUserWithUserIndexAs5ThenThSendsGetYearDayScheduleCommandToDutWith_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: Create a new user with UserIndex as 5 then TH sends Get Year Day Schedule Command to DUT with: Error: %@", err); - } else { - NSLog(@"Step 7a: Create a new user with UserIndex as 5 then TH sends Get Year Day Schedule Command to DUT with: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bYearDayIndexAs10ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableUserIndexAs5_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NumberOfYearDaySchedulesSupportedPerUserValue copy]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: YearDayIndex as 10 (value is in the the range of step 1 but YearDay Schedule entry not available) : UserIndex as 5: Error: %@", err); - } else { - NSLog(@"Step 7b: YearDayIndex as 10 (value is in the the range of step 1 but YearDay Schedule entry not available) : UserIndex as 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, NumberOfYearDaySchedulesSupportedPerUserValue)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 5U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs1BUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 1 b)UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 1 b)UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1ValueIsInTheTheRangeOfStep1ButYearDayScheduleEntryNotAvailableBUserDayIndexAs1_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (value is in the the range of step 1 but YearDay Schedule entry not available) b)UserDayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (value is in the the range of step 1 but YearDay Schedule entry not available) b)UserDayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsSetYearDayScheduleCommandToDutWithTheFollowingValuesAYearDayIndexAs1BUserIndexAs1CLocalStartTimeAs1080SecondsDLocalEndTimeAs2100Seconds_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1080UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:2100UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 1080 Seconds d)LocalEndTime as 2100 Seconds: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT with the following values: a)YearDayIndex as 1 b)UserIndex as 1 c)LocalStartTime as 1080 Seconds d)LocalEndTime as 2100 Seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1BUserDayIndexAs1_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 1 b)UserDayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT with : a)YearDayIndex as 1 b)UserDayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1080UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 2100UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 1081UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsGetYearDayScheduleCommandToDutWithAYearDayIndexAs1IndexOfExistingScheduleEntryBUserIndexAs2IndexOnNonExistentUser_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Error: %@", err); - } else { - NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT with a)YearDayIndex as 1 (index of existing Schedule entry) b)UserIndex as 2 (index on non-existent User): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsClearYearDayScheduleToDutWithAYearDayIndexAs0InvalidValueBUserIndexAs0InvalidValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 0(Invalid value) b)UserIndex as 0 (Invalid value): Error: %@", err); - } else { - NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT with a)YearDayIndex as 0(Invalid value) b)UserIndex as 0 (Invalid value): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAYearDayScheduleForTheFirstUser_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a year day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a year day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex1_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user with UserIndex 1: Error: %@", err); - } else { - NSLog(@"Cleanup the created user with UserIndex 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex5_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user with UserIndex 5: Error: %@", err); - } else { - NSLog(@"Cleanup the created user with UserIndex 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_8 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_8() - : TestCommandBridge("Test_TC_DRLK_2_8") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_8() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_8\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends Get User Command to DUT with UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH sends Get User Command to DUT with UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.C1a.Rsp && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: TH sends Clear User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends Get User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - VerifyOrReturn(CheckValue("clusterStatus present", status.mClusterStatus.HasValue(), true)); - VerifyOrReturn(CheckValue("clusterStatus value", status.mClusterStatus.Value(), 3)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull Current_NumberOfTotalUsersSupported; - - CHIP_ERROR TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - Current_NumberOfTotalUsersSupported = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:10U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:8965UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); - } else { - NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_11() - : TestCommandBridge("Test_TC_DRLK_2_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("PINCredentialData", &mPINCredentialData); - AddArgument("RFIDCredentialData", &mRFIDCredentialData); - AddArgument("FingerVeinCredentialData", &mFingerVeinCredentialData); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user with default parameters\n"); - err = TestPreconditionCreateNewUserWithDefaultParameters_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads MinPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads MaxPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1d: TH reads MinRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A001a")) { - NextTest(); - return; - } - err = TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1e: TH reads MaxRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A0019")) { - NextTest(); - return; - } - err = TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a: TH sends Set Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: TH sends Set Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH sends Set Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3a: TH sends Get Credential Status Command with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH sends Clear Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: TH sends Clear Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4e: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4f: TH sends Clear Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5a: TH sends Get Credential Status Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5b: TH sends Get Credential Status Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPINCredentialData; - chip::Optional mRFIDCredentialData; - chip::Optional mFingerVeinCredentialData; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUserWithDefaultParameters_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user with default parameters: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user with default parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mPINCredentialData.HasValue() ? [NSData dataWithBytes:mPINCredentialData.Value().data() length:mPINCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mRFIDCredentialData.HasValue() ? [NSData dataWithBytes:mRFIDCredentialData.Value().data() length:mRFIDCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mFingerVeinCredentialData.HasValue() ? [NSData dataWithBytes:mFingerVeinCredentialData.Value().data() length:mFingerVeinCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestGroupsCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestGroupsCluster() - : TestCommandBridge("TestGroupsCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestGroupsCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGroupsCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGroupsCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : View Group 0 (invalid)\n"); - err = TestViewGroup0Invalid_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : View First Group (not found)\n"); - err = TestViewFirstGroupNotFound_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Add First Group (no keys)\n"); - err = TestAddFirstGroupNoKeys_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Add KeySet\n"); - err = TestAddKeySet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write Group Keys\n"); - err = TestWriteGroupKeys_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Add First Group (name too long)\n"); - err = TestAddFirstGroupNameTooLong_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Add First Group (new)\n"); - err = TestAddFirstGroupNew_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : View First Group (new)\n"); - err = TestViewFirstGroupNew_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : View Second Group (not found)\n"); - err = TestViewSecondGroupNotFound_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Get Group Membership 1 (all)\n"); - err = TestGetGroupMembership1All_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Add Second Group (new)\n"); - err = TestAddSecondGroupNew_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : View Second Group (new)\n"); - err = TestViewSecondGroupNew_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : View Group 3 (not found)\n"); - err = TestViewGroup3NotFound_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : View First Group (existing)\n"); - err = TestViewFirstGroupExisting_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : View Second Group (existing)\n"); - err = TestViewSecondGroupExisting_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Get Group Membership 2\n"); - err = TestGetGroupMembership2_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Remove Group 0 (invalid)\n"); - err = TestRemoveGroup0Invalid_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Remove Group 4 (not found)\n"); - err = TestRemoveGroup4NotFound_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Remove Second Group (existing)\n"); - err = TestRemoveSecondGroupExisting_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : View First Group (not removed)\n"); - err = TestViewFirstGroupNotRemoved_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : View Second Group (removed)\n"); - err = TestViewSecondGroupRemoved_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Get Group Membership 3\n"); - err = TestGetGroupMembership3_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Remove All\n"); - err = TestRemoveAll_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : View First Group (removed)\n"); - err = TestViewFirstGroupRemoved_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : View Second Group (still removed)\n"); - err = TestViewSecondGroupStillRemoved_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : View Group 3 (removed)\n"); - err = TestViewGroup3Removed_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Get Group Membership 4\n"); - err = TestGetGroupMembership4_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestViewGroup0Invalid_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 0 (invalid): Error: %@", err); - } else { - NSLog(@"View Group 0 (invalid): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNotFound_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (not found): Error: %@", err); - } else { - NSLog(@"View First Group (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNoKeys_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"Group #1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (no keys): Error: %@", err); - } else { - NSLog(@"Add First Group (no keys): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 126U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddKeySet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add KeySet: Error: %@", err); - } else { - NSLog(@"Add KeySet: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteGroupKeys_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = - [NSNumber numberWithUnsignedShort:257U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = - [NSNumber numberWithUnsignedShort:258U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Group Keys: Error: %@", err); - } else { - NSLog(@"Write Group Keys: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNameTooLong_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"12345678901234567"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (name too long): Error: %@", err); - } else { - NSLog(@"Add First Group (name too long): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNew_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"Group #101234567"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (new): Error: %@", err); - } else { - NSLog(@"Add First Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNew_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (new): Error: %@", err); - } else { - NSLog(@"View First Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupNotFound_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (not found): Error: %@", err); - } else { - NSLog(@"View Second Group (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership1All_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 1 (all): Error: %@", err); - } else { - NSLog(@"Get Group Membership 1 (all): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddSecondGroupNew_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - params.groupName = @"Group #2"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add Second Group (new): Error: %@", err); - } else { - NSLog(@"Add Second Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupNew_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (new): Error: %@", err); - } else { - NSLog(@"View Second Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewGroup3NotFound_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:32767U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 3 (not found): Error: %@", err); - } else { - NSLog(@"View Group 3 (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupExisting_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (existing): Error: %@", err); - } else { - NSLog(@"View First Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupExisting_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (existing): Error: %@", err); - } else { - NSLog(@"View Second Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership2_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:259U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:32767U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 2: Error: %@", err); - } else { - NSLog(@"Get Group Membership 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGroup0Invalid_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Group 0 (invalid): Error: %@", err); - } else { - NSLog(@"Remove Group 0 (invalid): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGroup4NotFound_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:260U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Group 4 (not found): Error: %@", err); - } else { - NSLog(@"Remove Group 4 (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 260U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSecondGroupExisting_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Second Group (existing): Error: %@", err); - } else { - NSLog(@"Remove Second Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNotRemoved_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (not removed): Error: %@", err); - } else { - NSLog(@"View First Group (not removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupRemoved_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (removed): Error: %@", err); - } else { - NSLog(@"View Second Group (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership3_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:257U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[3] = - [NSNumber numberWithUnsignedShort:3U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 3: Error: %@", err); - } else { - NSLog(@"Get Group Membership 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveAll_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove All: Error: %@", err); - } else { - NSLog(@"Remove All: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupRemoved_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (removed): Error: %@", err); - } else { - NSLog(@"View First Group (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupStillRemoved_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (still removed): Error: %@", err); - } else { - NSLog(@"View Second Group (still removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewGroup3Removed_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:32767U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 3 (removed): Error: %@", err); - } else { - NSLog(@"View Group 3 (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership4_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:257U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[3] = - [NSNumber numberWithUnsignedShort:3U]; - temp_0[4] = - [NSNumber numberWithUnsignedShort:32767U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 4: Error: %@", err); - } else { - NSLog(@"Get Group Membership 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_G_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_G_1_1() - : TestCommandBridge("Test_TC_G_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_G_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_G_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_G_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !G.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given G.S.F00 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("G.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestScenesFabricRemoval : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestScenesFabricRemoval() - : TestCommandBridge("TestScenesFabricRemoval") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); - AddArgument("PakeVerifier", &mPakeVerifier); - AddArgument("G1", 0, UINT16_MAX, &mG1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestScenesFabricRemoval() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestScenesFabricRemoval\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestScenesFabricRemoval\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH1\n"); - err = TestCommissionDutToTh1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); - err = TestTh1ReadsTheFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Waiting after opening commissioning window\n"); - err = TestWaitingAfterOpeningCommissioningWindow_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from TH2\n"); - err = TestCommissionFromTh2_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for TH2\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : TH2 reads the fabric index\n"); - err = TestTh2ReadsTheFabricIndex_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : TH1 sends a RemoveAllGroups command to DUT.\n"); - err = TestTh1SendsARemoveAllGroupsCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : TH 1 Add Group KeySet.\n"); - err = TestTh1AddGroupKeySet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH1 Map KeySets to GroupId.\n"); - err = TestTh1MapKeySetsToGroupId_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH1 sends a AddGroup command to DUT for G1.\n"); - err = TestTh1SendsAAddGroupCommandToDutForG1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Preparation step : TH2 Add Group KeySet.\n"); - err = TestPreparationStepTh2AddGroupKeySet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Preparation step TH2 Map KeySets to GroupId.\n"); - err = TestPreparationStepTh2MapKeySetsToGroupId_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH2 sends a AddGroup command to DUT for G1.\n"); - err = TestTh2SendsAAddGroupCommandToDutForG1_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH1 confirms its Scene table is empty and gets its capacity\n"); - err = TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : TH2 confirms its Scene table is empty and has the same capacity as TH1\n"); - err = TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH1 sends an AddScene command to DUT for Scene 1 G1\n"); - err = TestTh1SendsAnAddSceneCommandToDutForScene1G1_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : TH1 sends an AddScene command to DUT for Scene 2 G1\n"); - err = TestTh1SendsAnAddSceneCommandToDutForScene2G1_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : TH2 sends an AddScene command to DUT for Scene 1 G1\n"); - err = TestTh2SendsAnAddSceneCommandToDutForScene1G1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : TH2 sends an AddScene command to DUT for Scene 2 G1\n"); - err = TestTh2SendsAnAddSceneCommandToDutForScene2G1_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : TH1 confirms its G1 holds 2 scenes\n"); - err = TestTh1ConfirmsItsG1Holds2Scenes_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : TH2 confirms its G1 holds 2 scenes\n"); - err = TestTh2ConfirmsItsG1Holds2Scenes_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH1 sends RemoveFabric command for TH2\n"); - err = TestTh1SendsRemoveFabricCommandForTh2_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : TH1 confirms its G1 still holds 2 scenes\n"); - err = TestTh1ConfirmsItsG1StillHolds2Scenes_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mDiscriminator; - chip::Optional mWaitAfterCommissioning; - chip::Optional mPakeVerifier; - chip::Optional mG1; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToTh1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th1FabricIndex; - - CHIP_ERROR TestTh1ReadsTheFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH1 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th1FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; - params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; - params.iterations = - [NSNumber numberWithUnsignedInt:1000UL]; - params.salt = - [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; - [cluster openCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCommissionFromTh2_4() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - NSNumber * _Nonnull th2FabricIndex; - - CHIP_ERROR TestTh2ReadsTheFabricIndex_6() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH2 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th2FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsARemoveAllGroupsCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Error: %@", err); - } else { - NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1AddGroupKeySet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH 1 Add Group KeySet.: Error: %@", err); - } else { - NSLog(@"TH 1 Add Group KeySet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1MapKeySetsToGroupId_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 Map KeySets to GroupId.: Error: %@", err); - } else { - NSLog(@"TH1 Map KeySets to GroupId.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAAddGroupCommandToDutForG1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Error: %@", err); - } else { - NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreparationStepTh2AddGroupKeySet_11() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:418U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1120000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1120001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1120002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Preparation step : TH2 Add Group KeySet.: Error: %@", err); - } else { - NSLog(@"Preparation step : TH2 Add Group KeySet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreparationStepTh2MapKeySetsToGroupId_12() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:418U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Error: %@", err); - } else { - NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAAddGroupCommandToDutForG1_13() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Error: %@", err); - } else { - NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable fabricCapacity; - - CHIP_ERROR TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Error: %@", err); - } else { - NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - fabricCapacity = values.capacity; - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Error: %@", err); - } else { - NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - if (fabricCapacity == nil) { - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, fabricCapacity)); - } - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene1G1_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:1UL]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); - } else { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene2G1_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:2U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:0UL]; - params.sceneName = @"Scene2"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); - } else { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene1G1_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:1000UL]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); - } else { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene2G1_19() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:2U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:0UL]; - params.sceneName = @"Scene2"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); - } else { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1ConfirmsItsG1Holds2Scenes_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its G1 holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH1 confirms its G1 holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2ConfirmsItsG1Holds2Scenes_21() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 confirms its G1 holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH2 confirms its G1 holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsRemoveFabricCommandForTh2_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [th2FabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends RemoveFabric command for TH2: Error: %@", err); - } else { - NSLog(@"TH1 sends RemoveFabric command for TH2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1ConfirmsItsG1StillHolds2Scenes_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its G1 still holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH1 confirms its G1 still holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_1_1() - : TestCommandBridge("Test_TC_S_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); - if (ShouldSkip("(!S.S.F00)")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); - if (ShouldSkip("(S.S.F00)")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList mandatory attributes(global attribute 65531)\n"); - if (ShouldSkip("S.S")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListMandatoryAttributesglobalAttribute65531_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("S.S")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529)\n"); - if (ShouldSkip("S.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7b: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528)\n"); - if (ShouldSkip("S.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep7bReadOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapNameSupportBitGlobalAttribute65532_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListMandatoryAttributesglobalAttribute65531_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList mandatory attributes(global attribute 65531): Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList mandatory attributes(global attribute 65531): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bReadOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); - } else { - NSLog(@"Step 7b: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_2_1() - : TestCommandBridge("Test_TC_S_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the LastConfiguredBy attribute\n"); - if (ShouldSkip("S.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheLastConfiguredByAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SceneTableSize attribute\n"); - if (ShouldSkip("S.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSceneTableSizeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the FabricSceneInfo attribute\n"); - if (ShouldSkip("S.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheFabricSceneInfoAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheLastConfiguredByAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastConfiguredByWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the LastConfiguredBy attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the LastConfiguredBy attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastConfiguredBy", "node_id", "node_id")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSceneTableSizeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSceneTableSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SceneTableSize attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SceneTableSize attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("sceneTableSize", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheFabricSceneInfoAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricSceneInfoWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the FabricSceneInfo attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the FabricSceneInfo attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fabricSceneInfo", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_2_4() - : TestCommandBridge("Test_TC_S_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("G1", 0, UINT16_MAX, &mG1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002\n"); - err = TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1\n"); - err = TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH sends a RemoveAllGroups command to DUT.\n"); - if (ShouldSkip("G.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep0cThSendsARemoveAllGroupsCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.\n"); - if (ShouldSkip("G.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.\n"); - if (ShouldSkip("S.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x4E20 (20s) and no extension fields set.\n"); - if (ShouldSkip("S.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x4E2020sAndNoExtensionFieldsSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); - if (ShouldSkip("S.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 1s for level to change\n"); - err = TestWait1sForLevelToChange_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.\n"); - if (ShouldSkip("S.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 20s\n"); - err = TestWait20s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH confirm the DUT reached AC1 (on level control cluster) after 20s\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : DUT transitions to AC1 over 20s.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestDutTransitionsToAc1Over20s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS")) { - NextTest(); - return; - } - err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 5000 (5s).\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS")) { - NextTest(); - return; - } - err = TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo50005s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 5s\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS")) { - NextTest(); - return; - } - err = TestWait5s_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH confirm the DUT reached AC2 (on level control cluster) after 5s\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME_MS && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : DUT transitions to AC1 over 5.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestDutTransitionsToAc1Over5_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).\n"); - if (ShouldSkip("S.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1\n"); - err = TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mG1; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Error: %@", err); - } else { - NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Error: %@", err); - } else { - NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0cThSendsARemoveAllGroupsCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Error: %@", err); - } else { - NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRemoveAllScenesParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster removeAllScenesWithParams:params completion: - ^(MTRScenesManagementClusterRemoveAllScenesResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x4E2020sAndNoExtensionFieldsSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:20000UL]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x4E20 (20s) and no extension fields set.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x4E20 (20s) and no extension fields set.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC1 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterStoreSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - [cluster storeSceneWithParams:params completion: - ^(MTRScenesManagementClusterStoreSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1sForLevelToChange_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait20s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 20500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutTransitionsToAc1Over20s_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please confirm that transition to AC1 was made over 20sgarbage: not in length on purpose", 55); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo50005s_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedInt:5000UL]; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 5000 (5s).: Error: %@", err); - } else { - NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 5000 (5s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutTransitionsToAc1Over5_23() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please confirm that transition to AC1 was made over 5sgarbage: not in length on purpose", 54); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = nil; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Error: %@", err); - } else { - NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Error: %@", err); - } else { - NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestActivatedCarbonFilterMonitoring : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestActivatedCarbonFilterMonitoring() - : TestCommandBridge("TestActivatedCarbonFilterMonitoring") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestActivatedCarbonFilterMonitoring() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestActivatedCarbonFilterMonitoring\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestActivatedCarbonFilterMonitoring\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); - err = TestValidateTheFeatureMap_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); - err = TestReadReplacementProductList_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestValidateTheFeatureMap_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate the feature map: Error: %@", err); - } else { - NSLog(@"Validate the feature map: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadReplacementProductList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Replacement Product List: Error: %@", err); - } else { - NSLog(@"Read Replacement Product List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestHepaFilterMonitoring : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestHepaFilterMonitoring() - : TestCommandBridge("TestHepaFilterMonitoring") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestHepaFilterMonitoring() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestHepaFilterMonitoring\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestHepaFilterMonitoring\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); - err = TestValidateTheFeatureMap_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); - err = TestReadReplacementProductList_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestValidateTheFeatureMap_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate the feature map: Error: %@", err); - } else { - NSLog(@"Validate the feature map: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadReplacementProductList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Replacement Product List: Error: %@", err); - } else { - NSLog(@"Read Replacement Product List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACFREMON_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACFREMON_1_1() - : TestCommandBridge("Test_TC_ACFREMON_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACFREMON_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!ACFREMON.S.F00 && !ACFREMON.S.F01 && !ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given ACFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenACFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip("!ACFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); - if (ShouldSkip("ACFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenACFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given ACFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given ACFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACFREMON_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACFREMON_2_1() - : TestCommandBridge("Test_TC_ACFREMON_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACFREMON_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); - if (ShouldSkip("ACFREMON.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); - if (ShouldSkip("ACFREMON.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("ACFREMON.S.A0002 && !ACFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheChangeIndicationAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4b: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("ACFREMON.S.F01 && ACFREMON.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheChangeIndicationAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); - if (ShouldSkip("ACFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); - if (ShouldSkip("ACFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); - if (ShouldSkip("ACFREMON.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheChangeIndicationAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheChangeIndicationAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ChangeIndication", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_HEPAFREMON_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_HEPAFREMON_1_1() - : TestCommandBridge("Test_TC_HEPAFREMON_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_HEPAFREMON_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!HEPAFREMON.S.F00 && !HEPAFREMON.S.F01 && !HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip("!HEPAFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); - if (ShouldSkip("HEPAFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_HEPAFREMON_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_HEPAFREMON_2_1() - : TestCommandBridge("Test_TC_HEPAFREMON_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_HEPAFREMON_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); - if (ShouldSkip("HEPAFREMON.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); - if (ShouldSkip("HEPAFREMON.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("HEPAFREMON.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("changeIndication", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("changeIndication", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -#endif // CONFIG_ENABLE_YAML_TESTS - -void registerCommandsTests(Commands & commands) -{ - const char * clusterName = "Tests"; - - commands_list clusterCommands = { -#if CONFIG_ENABLE_YAML_TESTS - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), -#endif // CONFIG_ENABLE_YAML_TESTS - }; - - commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for running YAML tests."); -}