From 106243638af456f7ac5e426d3ce33e0b15e21922 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Fri, 13 Oct 2023 20:49:24 -0400 Subject: [PATCH] [Scenes] Activated the automated yamls for scenes on CI (#29714) * Activated the automated yamls for scenes on CI * Added Scenes test to the darwin framework tool * Disabled test 2_2 for Repl as it used unsupported commands for this test and fixed the yaml for Darwin-framework-tool * Restyled by whitespace * Applied fix for Darwin build * Regenerated Zap * Fixed name support typing for Darwin tests --------- Co-authored-by: Restyled.io --- .../templates/tests/ciTests.json | 1 + scripts/tests/chiptest/__init__.py | 5 +- .../suites/certification/Test_TC_S_2_1.yaml | 4 +- .../suites/certification/Test_TC_S_2_2.yaml | 25 +- .../suites/certification/Test_TC_S_2_3.yaml | 11 +- .../suites/certification/Test_TC_S_2_4.yaml | 12 +- src/app/tests/suites/ciTests.json | 9 +- src/app/tests/suites/manualTests.json | 7 +- .../zap-generated/test/Commands.h | 3088 +++++++++++++++++ 9 files changed, 3121 insertions(+), 41 deletions(-) diff --git a/examples/darwin-framework-tool/templates/tests/ciTests.json b/examples/darwin-framework-tool/templates/tests/ciTests.json index d3d9dcb2f04581..0d4527d435aad8 100644 --- a/examples/darwin-framework-tool/templates/tests/ciTests.json +++ b/examples/darwin-framework-tool/templates/tests/ciTests.json @@ -52,6 +52,7 @@ "Disabled because darwin-framework-tool does not support GetCommissionerRootCertificate", "Test_AddNewFabricFromExistingFabric", "Disabled because darwin-framework-tool does not support EqualityCommands pseudo-cluster", + "Test_TC_S_2_2", "Test_TC_TCCM_3_1", "Test_TC_TCTL_2_1", "Disabled because darwin-framework-tool does not support constraints arithmetic operations", diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index 45e89df357c145..b665402846255f 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -157,7 +157,6 @@ def _GetInDevelopmentTests() -> Set[str]: # TestEventTriggersEnabled is true, which it's not in CI. "Test_TC_SMOKECO_2_6.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes # TestEventTriggersEnabled is true, which it's not in CI. - "Test_TC_S_2_4.yaml", # https://github.com/project-chip/connectedhomeip/issues/29117 } @@ -176,9 +175,7 @@ def _GetChipReplUnsupportedTests() -> Set[str]: "Test_TC_ACE_1_6.yaml", # Test fails only in chip-repl: Refer--> https://github.com/project-chip/connectedhomeip/pull/27910#issuecomment-1632485584 "Test_TC_IDM_1_2.yaml", # chip-repl does not support AnyCommands (19/07/2023) "TestGroupKeyManagementCluster.yaml", # chip-repl does not support EqualityCommands (2023-08-04) - "Test_TC_S_2_2.yaml", # chip-repl does not support scenes cluster commands - "Test_TC_S_2_3.yaml", # chip-repl does not support scenes cluster commands - "Test_TC_S_2_4.yaml", # chip-repl does not support scenes cluster commands + "Test_TC_S_2_2.yaml", # chip-repl does not support EqualityCommands pseudo-cluster "Test_TC_MOD_3_1.yaml", # chip-repl does not support EqualityCommands pseudo-cluster "Test_TC_MOD_3_2.yaml", # chip-repl does not support EqualityCommands pseudo-cluster "Test_TC_MOD_3_3.yaml", # chip-repl does not support EqualityCommands pseudo-cluster diff --git a/src/app/tests/suites/certification/Test_TC_S_2_1.yaml b/src/app/tests/suites/certification/Test_TC_S_2_1.yaml index ec9a9c3871768a..3e31cf836e1dd2 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_1.yaml @@ -73,7 +73,7 @@ tests: response: value: 0x80 constraints: - type: int8u + type: bitmap8 - label: "Step 6: TH reads from the DUT the (0x0004) NameSupport attribute" PICS: S.S.A0004 && (!S.S.F00) @@ -82,7 +82,7 @@ tests: response: value: 0x00 constraints: - type: int8u + type: bitmap8 - label: "Step 7: TH reads from the DUT the (0x0005) LastConfiguredBy attribute" diff --git a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml index a63a94b08262e9..f084d75cdc5370 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml @@ -23,15 +23,12 @@ config: cluster: "Scenes" endpoint: 1 G1: - type: int16u + type: group_id defaultValue: 0x0001 G2: - type: int16u + type: group_id defaultValue: 0x0002 - GroupKeyManagement.Endpoint: 0 - Groups.Endpoint: 1 - tests: - label: "Wait for the commissioned device to be retrieved" cluster: "DelayCommands" @@ -54,7 +51,7 @@ tests: "Step 0a: preparation step for using commands from Groups cluster: Add KeySet" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "KeySetWrite" arguments: values: @@ -75,7 +72,7 @@ tests: "Step 0b: Preparation step for using commands from Groups cluster: Write Group Keys" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "writeAttribute" attribute: "GroupKeyMap" arguments: @@ -88,7 +85,7 @@ tests: - label: "Step 0c: TH sends a RemoveAllGroups command to DUT." PICS: G.S.C04.Rsp cluster: "Groups" - endpoint: Groups.Endpoint + endpoint: endpoint command: "RemoveAllGroups" - label: @@ -330,7 +327,7 @@ tests: - label: "Step 4a: Reboot target device" PICS: PICS_SDK_CI_ONLY cluster: "SystemCommands" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "Reboot" - label: "Step 4a: Reboot target device(DUT)" @@ -1033,7 +1030,7 @@ tests: response: values: - name: "Status" - saveAs: StoreStatus + saveAs: StoredStatus constraints: anyOf: [0x00, 0x89] - name: "GroupID" @@ -1052,16 +1049,16 @@ tests: - name: "Value1" value: 0x00 - name: "Value2" - value: StoreStatus + value: StoredStatus response: - values: - name: "Equals" - saveAs: ContinueTest + saveAs: ContinueStep14 - label: "Step 14c: TH sends a GetSceneMembership command to DUT with the GroupID field set to G2." - runIf: ContinueTest + runIf: ContinueStep14 PICS: S.S.C06.Rsp command: "GetSceneMembership" arguments: @@ -1084,7 +1081,7 @@ tests: KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "KeySetRemove" arguments: values: diff --git a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml index b91f6eee39f3e3..5e0b5d21fa41ad 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml @@ -23,9 +23,8 @@ config: cluster: "Scenes" endpoint: 1 G1: - type: int16u + type: group_id defaultValue: 0x0101 - GroupKeyManagement.Endpoint: 0 tests: - label: "Wait for the commissioned device to be retrieved" @@ -49,7 +48,7 @@ tests: "Step 0a: preparation step for using commands from Groups cluster: Add KeySet" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "KeySetWrite" arguments: values: @@ -70,7 +69,7 @@ tests: "Step 0b: Preparation step for using commands from Groups cluster: Write Group Keys" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "writeAttribute" attribute: "GroupKeyMap" arguments: @@ -97,7 +96,7 @@ tests: - label: "Install ACLs" cluster: "Access Control" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "writeAttribute" attribute: "ACL" arguments: @@ -644,7 +643,7 @@ tests: KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "KeySetRemove" arguments: values: diff --git a/src/app/tests/suites/certification/Test_TC_S_2_4.yaml b/src/app/tests/suites/certification/Test_TC_S_2_4.yaml index 12657fc8dd8cce..6ee1346ce93e0a 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_4.yaml @@ -22,12 +22,9 @@ config: nodeId: 0x12344321 cluster: "Scenes" endpoint: 1 - - GroupKeyManagement.Endpoint: 0 G1: - type: int16u + type: group_id defaultValue: 0x0001 - Groups.Endpoint: 1 tests: - label: "Wait for the commissioned device to be retrieved" @@ -42,7 +39,7 @@ tests: "Step 0a: preparation step for using commands from Groups cluster: Add KeySet" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "KeySetWrite" arguments: values: @@ -63,7 +60,7 @@ tests: "Step 0b: Preparation step for using commands from Groups cluster: Write Group Keys" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "writeAttribute" attribute: "GroupKeyMap" arguments: @@ -72,7 +69,6 @@ tests: - label: "Step 0c: TH sends a RemoveAllGroups command to DUT." PICS: G.S.C04.Rsp cluster: "Groups" - endpoint: Groups.Endpoint command: "RemoveAllGroups" - label: @@ -423,7 +419,7 @@ tests: KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1" cluster: "Group Key Management" - endpoint: GroupKeyManagement.Endpoint + endpoint: 0 command: "KeySetRemove" arguments: values: diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 1f2d48eae8f5d5..d17ace003fefcb 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -318,7 +318,13 @@ "Test_TC_G_1_1", "Test_TC_G_2_1" ], - "Scenes": ["Test_TC_S_1_1"], + "Scenes": [ + "Test_TC_S_1_1", + "Test_TC_S_2_1", + "Test_TC_S_2_2", + "Test_TC_S_2_3", + "Test_TC_S_2_4" + ], "ResourceMonitoring": [ "TestActivatedCarbonFilterMonitoring", "TestHepaFilterMonitoring", @@ -413,6 +419,7 @@ "Subscriptions", "DoorLock", "Groups", + "Scenes", "ResourceMonitoring" ] } diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index e5c4da8fc77b85..a26fe6737a29c0 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -292,12 +292,7 @@ "TimeSynchronization": [], "UnitLocalization": [], "Binding": ["Test_TC_BIND_2_1", "Test_TC_BIND_2_2", "Test_TC_BIND_2_3"], - "Scenes": [ - "Test_TC_S_1_1", - "Test_TC_S_2_1", - "Test_TC_S_2_5", - "Test_TC_S_2_6" - ], + "Scenes": ["Test_TC_S_2_5", "Test_TC_S_2_6"], "PumpConfigurationControl": [], "AccessControl": [], "UserLabel": [], diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 79f6ffd707f254..9b2b20b3229423 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -295,6 +295,10 @@ class TestList : public Command { printf("Test_TC_DRLK_2_11\n"); printf("TestGroupsCluster\n"); printf("Test_TC_G_1_1\n"); + printf("Test_TC_S_1_1\n"); + printf("Test_TC_S_2_1\n"); + printf("Test_TC_S_2_3\n"); + printf("Test_TC_S_2_4\n"); printf("TestActivatedCarbonFilterMonitoring\n"); printf("TestHepaFilterMonitoring\n"); printf("Test_TC_ACFREMON_1_1\n"); @@ -171422,6 +171426,3086 @@ class Test_TC_G_1_1 : public TestCommandBridge { } }; +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: Read ClusterRevision (global attribute 65533)\n"); + err = TestStep2ReadClusterRevisionGlobalAttribute65533_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read FeatureMap (global attribute 65532)\n"); + if (ShouldSkip("(!S.S.F00)")) { + NextTest(); + return; + } + err = TestStep3aReadFeatureMapGlobalAttribute65532_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: Read FeatureMap (global attribute 65532)\n"); + if (ShouldSkip("S.S.F00")) { + NextTest(); + return; + } + err = TestStep3aReadFeatureMapGlobalAttribute65532_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Read Mandatory attributes in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("S.S")) { + NextTest(); + return; + } + err = TestStep4ReadMandatoryAttributesInAttributeListGlobalAttribute65531_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Read optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("(!S.S.F03)")) { + NextTest(); + return; + } + err = TestStep4bReadOptionalAttributesSceneCountCurrentSceneCurrentGroupSceneValidInAttributeListGlobalAttribute65531_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: Read optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("S.S.A0005")) { + NextTest(); + return; + } + err = TestStep4cReadOptinnalAttributeLastConfiguredByInAttributeListGlobalAttribute65531_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: Read optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("S.S.F02")) { + NextTest(); + return; + } + err = TestStep4dReadOptionnalAttributeSceneTableSizeInAttributeListGlobalAttribute65531_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: Read optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("S.S.F03")) { + NextTest(); + return; + } + err = TestStep4eReadOptionalAttributeFabricSceneInfoInAttributeListGlobalAttribute65531_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: Read EventList (global attribute 65530)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6a: Read Mandatory commands in AcceptedCommandList (global attribute 65529)\n"); + if (ShouldSkip("S.S")) { + NextTest(); + return; + } + err = TestStep6aReadMandatoryCommandsInAcceptedCommandListGlobalAttribute65529_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6b: Read optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529)\n"); + if (ShouldSkip("S.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep6bReadOptionalCommandEnhancedAddSceneResponseAcceptedCommandListGlobalAttribute65529_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6c: Read optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529)\n"); + if (ShouldSkip("S.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep6cReadOptionalCommandEnhancedViewSceneResponseAcceptedCommandListGlobalAttribute65529_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6d: Read optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529)\n"); + if (ShouldSkip("S.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep6dReadOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7a: Read GeneratedCommandList (global attribute 65528)\n"); + err = TestStep7aReadGeneratedCommandListGlobalAttribute65528_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7b: Read optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528)\n"); + if (ShouldSkip("S.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep7bReadOptionalCommandEnhancedAddSceneResponseInGeneratedCommandListGlobalAttribute65528_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7c: Read optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528)\n"); + if (ShouldSkip("S.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep7cReadOptionalCommandEnhancedViewSceneResponseInGeneratedCommandListGlobalAttribute65528_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 7d: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528)\n"); + if (ShouldSkip("S.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep7dReadOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_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 TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadClusterRevisionGlobalAttribute65533_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 2: Read ClusterRevision (global attribute 65533) Error: %@", err); + + 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 TestStep3aReadFeatureMapGlobalAttribute65532_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 3a: Read FeatureMap (global attribute 65532) Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadFeatureMapGlobalAttribute65532_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 3a: Read FeatureMap (global attribute 65532) Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ReadMandatoryAttributesInAttributeListGlobalAttribute65531_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 4: Read Mandatory attributes in AttributeList (global attribute 65531) Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + 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 TestStep4bReadOptionalAttributesSceneCountCurrentSceneCurrentGroupSceneValidInAttributeListGlobalAttribute65531_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 4b: Read optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531) Error: %@", err); + + 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)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadOptinnalAttributeLastConfiguredByInAttributeListGlobalAttribute65531_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 4c: Read optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531) Error: %@", err); + + 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 TestStep4dReadOptionnalAttributeSceneTableSizeInAttributeListGlobalAttribute65531_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 4d: Read optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531) Error: %@", err); + + 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 TestStep4eReadOptionalAttributeFabricSceneInfoInAttributeListGlobalAttribute65531_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 4e: Read optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531) Error: %@", err); + + 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 TestStep6aReadMandatoryCommandsInAcceptedCommandListGlobalAttribute65529_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 6a: Read Mandatory commands in AcceptedCommandList (global attribute 65529) Error: %@", err); + + 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 TestStep6bReadOptionalCommandEnhancedAddSceneResponseAcceptedCommandListGlobalAttribute65529_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 6b: Read optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529) Error: %@", err); + + 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 TestStep6cReadOptionalCommandEnhancedViewSceneResponseAcceptedCommandListGlobalAttribute65529_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 6c: Read optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529) Error: %@", err); + + 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 TestStep6dReadOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 6d: Read optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529) Error: %@", err); + + 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 TestStep7aReadGeneratedCommandListGlobalAttribute65528_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 7a: Read GeneratedCommandList (global attribute 65528) Error: %@", err); + + 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 TestStep7bReadOptionalCommandEnhancedAddSceneResponseInGeneratedCommandListGlobalAttribute65528_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 7b: Read optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528) Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 64UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7cReadOptionalCommandEnhancedViewSceneResponseInGeneratedCommandListGlobalAttribute65528_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 7c: Read optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528) Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 65UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7dReadOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 7d: Read optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528) Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 66UL)); + + 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: 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) SceneCount attribute\n"); + if (ShouldSkip("S.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutThe0x0000SceneCountAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) CurrentScene attribute\n"); + if (ShouldSkip("S.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutThe0x0001CurrentSceneAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the (0x0002) CurrentGroup attribute\n"); + if (ShouldSkip("S.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutThe0x0002CurrentGroupAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0003) SceneValid attribute\n"); + if (ShouldSkip("S.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThe0x0003SceneValidAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0004) NameSupport attribute\n"); + if (ShouldSkip("S.S.A0003 && S.S.F00")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThe0x0004NameSupportAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the (0x0004) NameSupport attribute\n"); + if (ShouldSkip("S.S.A0004 && (!S.S.F00)")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThe0x0004NameSupportAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the (0x0005) LastConfiguredBy attribute\n"); + if (ShouldSkip("S.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutThe0x0005LastConfiguredByAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads from the DUT the (0x0006) SceneTableSize attribute\n"); + if (ShouldSkip("S.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutThe0x0006SceneTableSizeAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH reads from the DUT the (0x0007) RemainingCapacity attribute\n"); + if (ShouldSkip("S.S.A0007")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutThe0x0007RemainingCapacityAttribute_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 TestStep2ThReadsFromTheDutThe0x0000SceneCountAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSceneCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 2: TH reads from the DUT the (0x0000) SceneCount attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("sceneCount", "int8u", "int8u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001CurrentSceneAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSceneWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentScene attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentScene", "int8u", "int8u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutThe0x0002CurrentGroupAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentGroupWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 4: TH reads from the DUT the (0x0002) CurrentGroup attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentGroup", "group_id", "group_id")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0003SceneValidAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSceneValidWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 5: TH reads from the DUT the (0x0003) SceneValid attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("sceneValid", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0004NameSupportAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNameSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 6: TH reads from the DUT the (0x0004) NameSupport attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NameSupport", actualValue, 128U)); + } + + VerifyOrReturn(CheckConstraintType("nameSupport", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0004NameSupportAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNameSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 6: TH reads from the DUT the (0x0004) NameSupport attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NameSupport", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintType("nameSupport", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0005LastConfiguredByAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLastConfiguredByWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 7: TH reads from the DUT the (0x0005) LastConfiguredBy attribute Error: %@", err); + + 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 TestStep8ThReadsFromTheDutThe0x0006SceneTableSizeAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSceneTableSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 8: TH reads from the DUT the (0x0006) SceneTableSize attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("sceneTableSize", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0007RemainingCapacityAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRemainingCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 9: TH reads from the DUT the (0x0007) RemainingCapacity attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("remainingCapacity", "int8u", "int8u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_S_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_S_2_3() + : TestCommandBridge("Test_TC_S_2_3") + , 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_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_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 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH reads from the DUT the (0x0006) SceneTableSize attribute\n"); + if (ShouldSkip("S.S.A0006")) { + NextTest(); + return; + } + err = TestThReadsFromTheDutThe0x0006SceneTableSizeAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0a: preparation step for using commands from Groups cluster: Add KeySet\n"); + err = TestStep0aPreparationStepForUsingCommandsFromGroupsClusterAddKeySet_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0b: Preparation step for using commands from Groups cluster: Write Group Keys\n"); + err = TestStep0bPreparationStepForUsingCommandsFromGroupsClusterWriteGroupKeys_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH sends a AddGroup command to DUT with the GroupID field set to G1.\n"); + if (ShouldSkip("G.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Install ACLs\n"); + err = TestInstallACLs_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.\n"); + if (ShouldSkip("S.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1c: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1.\n"); + if (ShouldSkip("S.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep1cThSendsAGetSceneMembershipCommandToDutWithTheGroupIDFieldSetToG1_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a: TH sends a EnhancedAddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x000a (1s) and a set of extension fields appropriate to AC1.\n"); + if (ShouldSkip("S.S.C40.Rsp && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep2aThSendsAEnhancedAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x000a1sAndASetOfExtensionFieldsAppropriateToAc1_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: 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 0x0001 (1s) and a set of extension fields appropriate to AC1.\n"); + if (ShouldSkip("S.S.C00.Rsp && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep2bThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x00011sAndASetOfExtensionFieldsAppropriateToAc1_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2a: TH sends a EnhancedAddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x000a and a set of extension fields appropriate to AC1.\n"); + if (ShouldSkip("S.S.C40.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2aThSendsAEnhancedAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x000aAndASetOfExtensionFieldsAppropriateToAc1_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: 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 G1 and a set of extension fields appropriate to AC1.\n"); + if (ShouldSkip("S.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2bThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetToG1AndASetOfExtensionFieldsAppropriateToAc1_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends a EnhancedViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); + if (ShouldSkip("S.S.C41.Rsp && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep3aThSendsAEnhancedViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH sends a ViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); + if (ShouldSkip("S.S.C01.Rsp && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep3bThSendsAViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: TH sends a EnhancedViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); + if (ShouldSkip("S.S.C41.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep3aThSendsAEnhancedViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH sends a ViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); + if (ShouldSkip("S.S.C01.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep3bThSendsAViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1.\n"); + if (ShouldSkip("S.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsAGetSceneMembershipCommandToDutWithTheGroupIDFieldSetToG1_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : 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_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : 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_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5b: TH sends a RecallScene command to group G1 with the GroupID field set to G1 and the scene ID field set to 0x01.\n"); + if (ShouldSkip("S.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep5bThSendsARecallSceneCommandToGroupG1WithTheGroupIDFieldSetToG1AndTheSceneIdFieldSetTo0x01_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 1s\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestWait1s_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : TH confirm the DUT reached AC1 (on level control cluster) after 1s\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY && S.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter1s_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Verify DUT returns to AC1.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestVerifyDutReturnsToAc1_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6a: TH sends a CopyScene command to DUT with the mode field set to 0x00, the group identifier from field set to G1, the scene identifier from field set to 0x01, the group identifier to field set to G1 and the scene identifier to field set to 0x02.\n"); + if (ShouldSkip("S.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep6aThSendsACopySceneCommandToDutWithTheModeFieldSetTo0x00TheGroupIdentifierFromFieldSetToG1TheSceneIdentifierFromFieldSetTo0x01TheGroupIdentifierToFieldSetToG1AndTheSceneIdentifierToFieldSetTo0x02_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 6b: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1.\n"); + if (ShouldSkip("S.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep6bThSendsAGetSceneMembershipCommandToDutWithTheGroupIDFieldSetToG1_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 7: 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 = TestStep7ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_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 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); + } + NSNumber * _Nonnull maxScenes; + + CHIP_ERROR TestThReadsFromTheDutThe0x0006SceneTableSizeAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSceneTableSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads from the DUT the (0x0006) SceneTableSize attribute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + maxScenes = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0aPreparationStepForUsingCommandsFromGroupsClusterAddKeySet_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: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) { + NSLog(@"Step 0a: preparation step for using commands from Groups cluster: Add KeySet Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bPreparationStepForUsingCommandsFromGroupsClusterWriteGroupKeys_3() + { + + 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:257U]; + ((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) { + NSLog(@"Step 0b: Preparation step for using commands from Groups cluster: Write Group Keys Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_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:257U]; + params.groupName = @"Group #1"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 1a: TH sends a AddGroup command to DUT with the GroupID field set to G1. Error: %@", err); + + 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() : 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestInstallACLs_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:4U]; + ((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) { + NSLog(@"Install ACLs Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterRemoveAllScenesParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + [cluster removeAllScenesWithParams:params completion: + ^(MTRScenesClusterRemoveAllScenesResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 1b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1. Error: %@", err); + + 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() : 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThSendsAGetSceneMembershipCommandToDutWithTheGroupIDFieldSetToG1_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 1c: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1. Error: %@", err); + + 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, [maxScenes unsignedShortValue] / 2U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 257U)); + } + + { + id actualValue = values.sceneList; + VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsAEnhancedAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x000a1sAndASetOfExtensionFieldsAppropriateToAc1_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterEnhancedAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:10U]; + params.sceneName = @"Scene1"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRScenesClusterExtensionFieldSet alloc] init]; + ((MTRScenesClusterExtensionFieldSet *) temp_0[0]).clusterID = + [NSNumber numberWithUnsignedInt:6UL]; + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = [[MTRScenesClusterAttributeValuePair alloc] init]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeID = + [NSNumber numberWithUnsignedInt:0UL]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeValue = + [NSNumber numberWithUnsignedInt:1UL]; + + ((MTRScenesClusterExtensionFieldSet *) temp_0[0]).attributeValueList = temp_2; + } + + temp_0[1] = [[MTRScenesClusterExtensionFieldSet alloc] init]; + ((MTRScenesClusterExtensionFieldSet *) temp_0[1]).clusterID = + [NSNumber numberWithUnsignedInt:8UL]; + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = [[MTRScenesClusterAttributeValuePair alloc] init]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeID = + [NSNumber numberWithUnsignedInt:0UL]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeValue = + [NSNumber numberWithUnsignedInt:100UL]; + + ((MTRScenesClusterExtensionFieldSet *) temp_0[1]).attributeValueList = temp_2; + } + + params.extensionFieldSets = temp_0; + } + [cluster enhancedAddSceneWithParams:params completion: + ^(MTRScenesClusterEnhancedAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 2a: TH sends a EnhancedAddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x000a (1s) and a set of extension fields appropriate to AC1. Error: %@", err); + + 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() : 257U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x00011sAndASetOfExtensionFieldsAppropriateToAc1_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:1U]; + params.sceneName = @"Scene1"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRScenesClusterExtensionFieldSet alloc] init]; + ((MTRScenesClusterExtensionFieldSet *) temp_0[0]).clusterID = + [NSNumber numberWithUnsignedInt:6UL]; + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = [[MTRScenesClusterAttributeValuePair alloc] init]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeID = + [NSNumber numberWithUnsignedInt:0UL]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeValue = + [NSNumber numberWithUnsignedInt:1UL]; + + ((MTRScenesClusterExtensionFieldSet *) temp_0[0]).attributeValueList = temp_2; + } + + temp_0[1] = [[MTRScenesClusterExtensionFieldSet alloc] init]; + ((MTRScenesClusterExtensionFieldSet *) temp_0[1]).clusterID = + [NSNumber numberWithUnsignedInt:8UL]; + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = [[MTRScenesClusterAttributeValuePair alloc] init]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeID = + [NSNumber numberWithUnsignedInt:0UL]; + ((MTRScenesClusterAttributeValuePair *) temp_2[0]).attributeValue = + [NSNumber numberWithUnsignedInt:100UL]; + + ((MTRScenesClusterExtensionFieldSet *) temp_0[1]).attributeValueList = temp_2; + } + + params.extensionFieldSets = temp_0; + } + [cluster addSceneWithParams:params completion: + ^(MTRScenesClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 2b: 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 0x0001 (1s) and a set of extension fields appropriate to AC1. Error: %@", err); + + 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() : 257U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsAEnhancedAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x000aAndASetOfExtensionFieldsAppropriateToAc1_10() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please execute the enhanced add scene command with extensionfieldsets in accordance with AC1 on DUT and enter 'y' if the command is successfulgarbage: not in length on purpose", 142); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetToG1AndASetOfExtensionFieldsAppropriateToAc1_11() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please execute the add scene command with extensionfieldsets in accordance with AC1 on DUT and enter 'y' if the command is successfulgarbage: not in length on purpose", 133); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3aThSendsAEnhancedViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterEnhancedViewSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + [cluster enhancedViewSceneWithParams:params completion: + ^(MTRScenesClusterEnhancedViewSceneResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 3a: TH sends a EnhancedViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01. Error: %@", err); + + 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() : 257U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + { + id actualValue = values.transitionTime; + VerifyOrReturn(CheckValue("TransitionTime", actualValue, 10U)); + } + + { + id actualValue = values.extensionFieldSets; + VerifyOrReturn(CheckValue("ExtensionFieldSets", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("ClusterID", ((MTRScenesClusterExtensionFieldSet *) actualValue[0]).clusterID, 6UL)); + VerifyOrReturn(CheckValue("AttributeValueList", [((MTRScenesClusterExtensionFieldSet *) actualValue[0]).attributeValueList count], static_cast(1))); + VerifyOrReturn(CheckValue("AttributeID", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[0]).attributeValueList[0]).attributeID, 0UL)); + VerifyOrReturn(CheckValue("AttributeValue", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[0]).attributeValueList[0]).attributeValue, 1UL)); + VerifyOrReturn(CheckValue("ClusterID", ((MTRScenesClusterExtensionFieldSet *) actualValue[1]).clusterID, 8UL)); + VerifyOrReturn(CheckValue("AttributeValueList", [((MTRScenesClusterExtensionFieldSet *) actualValue[1]).attributeValueList count], static_cast(1))); + VerifyOrReturn(CheckValue("AttributeID", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[1]).attributeValueList[0]).attributeID, 0UL)); + VerifyOrReturn(CheckValue("AttributeValue", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[1]).attributeValueList[0]).attributeValue, 100UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThSendsAViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterViewSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + [cluster viewSceneWithParams:params completion: + ^(MTRScenesClusterViewSceneResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 3b: TH sends a ViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01. Error: %@", err); + + 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() : 257U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + { + id actualValue = values.transitionTime; + VerifyOrReturn(CheckValue("TransitionTime", actualValue, 1U)); + } + + { + id actualValue = values.extensionFieldSets; + VerifyOrReturn(CheckValue("ExtensionFieldSets", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("ClusterID", ((MTRScenesClusterExtensionFieldSet *) actualValue[0]).clusterID, 6UL)); + VerifyOrReturn(CheckValue("AttributeValueList", [((MTRScenesClusterExtensionFieldSet *) actualValue[0]).attributeValueList count], static_cast(1))); + VerifyOrReturn(CheckValue("AttributeID", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[0]).attributeValueList[0]).attributeID, 0UL)); + VerifyOrReturn(CheckValue("AttributeValue", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[0]).attributeValueList[0]).attributeValue, 1UL)); + VerifyOrReturn(CheckValue("ClusterID", ((MTRScenesClusterExtensionFieldSet *) actualValue[1]).clusterID, 8UL)); + VerifyOrReturn(CheckValue("AttributeValueList", [((MTRScenesClusterExtensionFieldSet *) actualValue[1]).attributeValueList count], static_cast(1))); + VerifyOrReturn(CheckValue("AttributeID", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[1]).attributeValueList[0]).attributeID, 0UL)); + VerifyOrReturn(CheckValue("AttributeValue", ((MTRScenesClusterAttributeValuePair *) ((MTRScenesClusterExtensionFieldSet *) actualValue[1]).attributeValueList[0]).attributeValue, 100UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsAEnhancedViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_14() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please execute the ehanced-view-scene command and verify that the extensionfieldsets, status, groupID and SceneID are in accordance with AC1 on DUT and enter 'y' if the command is successfulgarbage: not in length on purpose", 190); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3bThSendsAViewSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_15() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please execute the view-scene command and verify that the extensionfieldsets, status, groupID and SceneID are in accordance with AC1 on DUT and enter 'y' if the command is successfulgarbage: not in length on purpose", 182); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4ThSendsAGetSceneMembershipCommandToDutWithTheGroupIDFieldSetToG1_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 4: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1. Error: %@", err); + + 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, ([maxScenes unsignedShortValue] / 2U) - 1U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 257U)); + } + + { + id actualValue = values.sceneList; + VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_17() + { + + 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) { + NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes. Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18() + { + + 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 TestStep5bThSendsARecallSceneCommandToGroupG1WithTheGroupIDFieldSetToG1AndTheSceneIdFieldSetTo0x01_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterRecallSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + [cluster recallSceneWithParams:params completion: + ^(NSError * _Nullable err) { + NSLog(@"Step 5b: TH sends a RecallScene command to group G1 with the GroupID field set to G1 and the scene ID field set to 0x01. Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1s_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1050UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter1s_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) { + NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 1s Error: %@", err); + + 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 TestVerifyDutReturnsToAc1_22() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please confirm AC1 on DUT and enter 'y'.garbage: not in length on purpose", 40); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6aThSendsACopySceneCommandToDutWithTheModeFieldSetTo0x00TheGroupIdentifierFromFieldSetToG1TheSceneIdentifierFromFieldSetTo0x01TheGroupIdentifierToFieldSetToG1AndTheSceneIdentifierToFieldSetTo0x02_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterCopySceneParams alloc] init]; + params.mode = + [NSNumber numberWithUnsignedChar:0U]; + params.groupIdentifierFrom = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + params.sceneIdentifierFrom = + [NSNumber numberWithUnsignedChar:1U]; + params.groupIdentifierTo = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + params.sceneIdentifierTo = + [NSNumber numberWithUnsignedChar:2U]; + [cluster copySceneWithParams:params completion: + ^(MTRScenesClusterCopySceneResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 6a: TH sends a CopyScene command to DUT with the mode field set to 0x00, the group identifier from field set to G1, the scene identifier from field set to 0x01, the group identifier to field set to G1 and the scene identifier to field set to 0x02. Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupIdentifierFrom; + VerifyOrReturn(CheckValue("GroupIdentifierFrom", actualValue, mG1.HasValue() ? mG1.Value() : 257U)); + } + + { + id actualValue = values.sceneIdentifierFrom; + VerifyOrReturn(CheckValue("SceneIdentifierFrom", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThSendsAGetSceneMembershipCommandToDutWithTheGroupIDFieldSetToG1_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:257U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 6b: TH sends a GetSceneMembership command to DUT with the GroupID field set to G1. Error: %@", err); + + 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, ([maxScenes unsignedShortValue] / 2U) - 2U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 257U)); + } + + { + 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 TestStep7ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_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 = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + [cluster keySetRemoveWithParams:params completion: + ^(NSError * _Nullable err) { + NSLog(@"Step 7: 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); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + 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: preparation step for using commands from Groups cluster: Add KeySet\n"); + err = TestStep0aPreparationStepForUsingCommandsFromGroupsClusterAddKeySet_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: Preparation step for using commands from Groups cluster: Write Group Keys\n"); + err = TestStep0bPreparationStepForUsingCommandsFromGroupsClusterWriteGroupKeys_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 0x0001 and a set of extension fields appropriate to AC1.\n"); + if (ShouldSkip("S.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x0001AndASetOfExtensionFieldsAppropriateToAc1_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")) { + 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 0x0032 (5s).\n"); + if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { + NextTest(); + return; + } + err = TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo0x00325s_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 5s\n"); + if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { + 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 && 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 TestStep0aPreparationStepForUsingCommandsFromGroupsClusterAddKeySet_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) { + NSLog(@"Step 0a: preparation step for using commands from Groups cluster: Add KeySet Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bPreparationStepForUsingCommandsFromGroupsClusterWriteGroupKeys_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) { + NSLog(@"Step 0b: Preparation step for using commands from Groups cluster: Write Group Keys Error: %@", err); + + 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) { + NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT. Error: %@", err); + + 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) { + NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1. Error: %@", err); + + 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 = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterRemoveAllScenesParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster removeAllScenesWithParams:params completion: + ^(MTRScenesClusterRemoveAllScenesResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1. Error: %@", err); + + 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 TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x0001AndASetOfExtensionFieldsAppropriateToAc1_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:20U]; + params.sceneName = @"Scene1"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.extensionFieldSets = temp_0; + } + [cluster addSceneWithParams:params completion: + ^(MTRScenesClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + 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 0x0001 and a set of extension fields appropriate to AC1. Error: %@", err); + + 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) { + NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes. Error: %@", err); + + 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 = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterStoreSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + [cluster storeSceneWithParams:params completion: + ^(MTRScenesClusterStoreSceneResponseParams * _Nullable values, NSError * _Nullable err) { + 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); + + 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) { + NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes. Error: %@", err); + + 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) { + NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1 Error: %@", err); + + 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 = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterRecallSceneParams 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) { + 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); + + 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) { + NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s Error: %@", err); + + 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) { + NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes. Error: %@", err); + + 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 TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo0x00325s_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterRecallSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:50U]; + [cluster recallSceneWithParams:params completion: + ^(NSError * _Nullable err) { + 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 0x0032 (5s). Error: %@", err); + + 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) { + NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s Error: %@", err); + + 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) { + NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes. Error: %@", err); + + 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 = [[MTRBaseClusterScenes alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesClusterRecallSceneParams 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) { + 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); + + 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) { + 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); + + 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 @@ -173653,6 +176737,10 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(),