From e5276112fc31e2648d331089768451209f2c2fb4 Mon Sep 17 00:00:00 2001 From: William Date: Tue, 24 Sep 2024 18:05:41 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20the=20service=20area=20server=20to=20ch?= =?UTF-8?q?eck=20if=20there=20are=20any=20selected=20area=E2=80=A6=20(#357?= =?UTF-8?q?22)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed the service area server to check if there are any selected areas when hadling the skip area command. * Restyled by clang-format * Restyled by autopep8 * Update src/python_testing/TC_SEAR_1_5.py Co-authored-by: Petru Lauric <81822411+plauric@users.noreply.github.com> --------- Co-authored-by: Restyled.io Co-authored-by: Petru Lauric <81822411+plauric@users.noreply.github.com> --- .../service-area-server.cpp | 13 +++++++++--- src/python_testing/TC_SEAR_1_5.py | 20 +++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/app/clusters/service-area-server/service-area-server.cpp b/src/app/clusters/service-area-server/service-area-server.cpp index 55ee2ab27c9943..b474d8ee87df95 100644 --- a/src/app/clusters/service-area-server/service-area-server.cpp +++ b/src/app/clusters/service-area-server/service-area-server.cpp @@ -378,12 +378,19 @@ void Instance::HandleSkipAreaCmd(HandlerContext & ctx, const Commands::SkipArea: ctx.mCommandHandler.AddResponse(ctx.mRequestPath, response); }; - // The SkippedArea field SHALL match an entry in the SupportedAreas list. - // If the Status field is set to InvalidAreaList, the StatusText field SHALL be an empty string. + // If the SelectedAreas attribute is empty, the SkipAreaResponse command’s Status field SHALL indicate InvalidAreaList. + if (GetNumberOfSelectedAreas() == 0) + { + exitResponse(SkipAreaStatus::kInvalidAreaList, ""_span); + return; + } + + // If the SkippedArea field does not match an entry in the SupportedAreas attribute, the SkipAreaResponse command’s Status field + // SHALL indicate InvalidSkippedArea. if (!mStorageDelegate->IsSupportedArea(req.skippedArea)) { ChipLogError(Zcl, "SkippedArea (%" PRIu32 ") is not in the SupportedAreas attribute.", req.skippedArea); - exitResponse(SkipAreaStatus::kInvalidAreaList, ""_span); + exitResponse(SkipAreaStatus::kInvalidSkippedArea, ""_span); return; } diff --git a/src/python_testing/TC_SEAR_1_5.py b/src/python_testing/TC_SEAR_1_5.py index 50b9080dff08c2..d4704d686a61e4 100644 --- a/src/python_testing/TC_SEAR_1_5.py +++ b/src/python_testing/TC_SEAR_1_5.py @@ -115,26 +115,30 @@ async def test_TC_SEAR_1_5(self): if self.check_pics("SEAR.S.M.INVALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that prevents it from executing the SkipArea command \ - (e.g. set CurrentArea to null or make it not operate, i.e. be in the idle state)" + (e.g. set CurrentArea to null or make it not operate, i.e. be in the idle state). Ensure that SelectedArea is not empty." self.print_step("3", test_step) - if not self.is_ci: + if self.is_ci: + await self.send_single_cmd(cmd=Clusters.Objects.ServiceArea.Commands.SelectAreas(newAreas=[7]), + endpoint=self.endpoint) + else: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id, - expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidInMode) + await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id, + expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidInMode) if self.check_pics("SEAR.S.M.NO_SELAREA_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state where the state would allow it to execute the SkipArea command, \ if SelectedAreas wasn't empty, and SelectedAreas is empty" self.print_step("5", test_step) if self.is_ci: + self.write_to_app_pipe({"Name": "Reset"}) await self.send_single_cmd(cmd=Clusters.Objects.RvcRunMode.Commands.ChangeToMode(newMode=1), endpoint=self.endpoint) else: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id, - expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidAreaList) + await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id, + expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidAreaList) if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"): test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command" @@ -148,8 +152,8 @@ async def test_TC_SEAR_1_5(self): else: self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n") - await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id, - expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidSkippedArea) + await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id, + expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidSkippedArea) if not self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP"): return