diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 80fc2d2ee27f37..cb797a2052bf9d 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -20,7 +20,7 @@ PICS: - label: "Does the device support discovery over WiFi?" id: WIFI - + - label: "Does the device support discover over THREAD" id: THREAD diff --git a/src/app/tests/suites/certification/Test_TC_DM_3_3_Simulated.yaml b/src/app/tests/suites/certification/Test_TC_DM_3_3_Simulated.yaml index e64cb1923e5214..6eb3d5e4f4b553 100644 --- a/src/app/tests/suites/certification/Test_TC_DM_3_3_Simulated.yaml +++ b/src/app/tests/suites/certification/Test_TC_DM_3_3_Simulated.yaml @@ -11,7 +11,7 @@ tests: - label: "Wait for Scan Network Command" wait: "ScanNetworks" - + - label: "Wait for Add Wifi Network Command" wait: "AddOrUpdateWiFiNetwork" PICS: WIFI @@ -22,9 +22,7 @@ tests: - label: "Wait for Enable Network Command" wait: "ConnectNetwork" - + - label: "Wait for Remove Network Command" wait: "RemoveNetwork" PICS: WIFI | THREAD - - diff --git a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h index 63199726f2da29..c31873ac740397 100644 --- a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h +++ b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h @@ -388,12 +388,187 @@ class Test_TC_DM_1_3_Simulated : public TestCommand } }; +class Test_TC_DM_3_3_Simulated : public TestCommand +{ +public: + Test_TC_DM_3_3_Simulated() : TestCommand("Test_TC_DM_3_3_Simulated"), mTestIndex(0) + { + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + } + + ~Test_TC_DM_3_3_Simulated() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DM_3_3_Simulated\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DM_3_3_Simulated\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we 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 device to be commissioned\n"); + err = TestWaitForTheDeviceToBeCommissioned_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for Scan Network Command\n"); + err = TestWaitForScanNetworkCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait for Add Wifi Network Command\n"); + if (ShouldSkip("WIFI")) + { + NextTest(); + return; + } + err = TestWaitForAddWifiNetworkCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for Update Thread Network Command\n"); + if (ShouldSkip("THREAD")) + { + NextTest(); + return; + } + err = TestWaitForUpdateThreadNetworkCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for Enable Network Command\n"); + err = TestWaitForEnableNetworkCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for Remove Network Command\n"); + if (ShouldSkip("WIFI | THREAD")) + { + NextTest(); + return; + } + err = TestWaitForRemoveNetworkCommand_5(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheDeviceToBeCommissioned_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissioning(); + } + + CHIP_ERROR TestWaitForScanNetworkCommand_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: ScanNetworks] Wait for Scan Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworks::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForAddWifiNetworkCommand_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError( + chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: AddOrUpdateWiFiNetwork] Wait for Add Wifi Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = + chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForUpdateThreadNetworkCommand_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: AddOrUpdateThreadNetwork] Wait for Update Thread " + "Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = + chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForEnableNetworkCommand_4() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: ConnectNetwork] Wait for Enable Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForRemoveNetworkCommand_5() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: RemoveNetwork] Wait for Remove Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::RemoveNetwork::Id); + return CHIP_NO_ERROR; + } +}; + std::unique_ptr GetTestCommand(std::string testName) { if (testName == "Test_TC_DM_1_3_Simulated") { return std::unique_ptr(new Test_TC_DM_1_3_Simulated()); } + if (testName == "Test_TC_DM_3_3_Simulated") + { + return std::unique_ptr(new Test_TC_DM_3_3_Simulated()); + } return nullptr; } @@ -402,4 +577,5 @@ void PrintTestCommands() { ChipLogError(chipTool, "Supported commands:"); ChipLogError(chipTool, "\t* Test_TC_DM_1_3_Simulated"); + ChipLogError(chipTool, "\t* Test_TC_DM_3_3_Simulated"); }