Skip to content

Commit

Permalink
Fixed the service area server to check if there are any selected area… (
Browse files Browse the repository at this point in the history
#35722)

* 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 <commits@restyled.io>
Co-authored-by: Petru Lauric <81822411+plauric@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 24, 2024
1 parent b6a1304 commit e527611
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
13 changes: 10 additions & 3 deletions src/app/clusters/service-area-server/service-area-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
20 changes: 12 additions & 8 deletions src/python_testing/TC_SEAR_1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit e527611

Please # to comment.