Skip to content

Commit e527611

Browse files
hicklinrestyled-commitsplauric
authored
Fixed the service area server to check if there are any selected area… (project-chip#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>
1 parent b6a1304 commit e527611

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/app/clusters/service-area-server/service-area-server.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,19 @@ void Instance::HandleSkipAreaCmd(HandlerContext & ctx, const Commands::SkipArea:
378378
ctx.mCommandHandler.AddResponse(ctx.mRequestPath, response);
379379
};
380380

381-
// The SkippedArea field SHALL match an entry in the SupportedAreas list.
382-
// If the Status field is set to InvalidAreaList, the StatusText field SHALL be an empty string.
381+
// If the SelectedAreas attribute is empty, the SkipAreaResponse command’s Status field SHALL indicate InvalidAreaList.
382+
if (GetNumberOfSelectedAreas() == 0)
383+
{
384+
exitResponse(SkipAreaStatus::kInvalidAreaList, ""_span);
385+
return;
386+
}
387+
388+
// If the SkippedArea field does not match an entry in the SupportedAreas attribute, the SkipAreaResponse command’s Status field
389+
// SHALL indicate InvalidSkippedArea.
383390
if (!mStorageDelegate->IsSupportedArea(req.skippedArea))
384391
{
385392
ChipLogError(Zcl, "SkippedArea (%" PRIu32 ") is not in the SupportedAreas attribute.", req.skippedArea);
386-
exitResponse(SkipAreaStatus::kInvalidAreaList, ""_span);
393+
exitResponse(SkipAreaStatus::kInvalidSkippedArea, ""_span);
387394
return;
388395
}
389396

src/python_testing/TC_SEAR_1_5.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,30 @@ async def test_TC_SEAR_1_5(self):
115115

116116
if self.check_pics("SEAR.S.M.INVALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"):
117117
test_step = "Manually intervene to put the device in a state that prevents it from executing the SkipArea command \
118-
(e.g. set CurrentArea to null or make it not operate, i.e. be in the idle state)"
118+
(e.g. set CurrentArea to null or make it not operate, i.e. be in the idle state). Ensure that SelectedArea is not empty."
119119
self.print_step("3", test_step)
120-
if not self.is_ci:
120+
if self.is_ci:
121+
await self.send_single_cmd(cmd=Clusters.Objects.ServiceArea.Commands.SelectAreas(newAreas=[7]),
122+
endpoint=self.endpoint)
123+
else:
121124
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
122125

123-
await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id,
124-
expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidInMode)
126+
await self.send_cmd_skip_area_expect_response(step=4, skipped_area=valid_area_id,
127+
expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidInMode)
125128

126129
if self.check_pics("SEAR.S.M.NO_SELAREA_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"):
127130
test_step = "Manually intervene to put the device in a state where the state would allow it to execute the SkipArea command, \
128131
if SelectedAreas wasn't empty, and SelectedAreas is empty"
129132
self.print_step("5", test_step)
130133
if self.is_ci:
134+
self.write_to_app_pipe({"Name": "Reset"})
131135
await self.send_single_cmd(cmd=Clusters.Objects.RvcRunMode.Commands.ChangeToMode(newMode=1),
132136
endpoint=self.endpoint)
133137
else:
134138
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
135139

136-
await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id,
137-
expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidAreaList)
140+
await self.send_cmd_skip_area_expect_response(step=6, skipped_area=valid_area_id,
141+
expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidAreaList)
138142

139143
if self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP") and self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"):
140144
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):
148152
else:
149153
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
150154

151-
await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id,
152-
expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidSkippedArea)
155+
await self.send_cmd_skip_area_expect_response(step=8, skipped_area=invalid_area_id,
156+
expected_response=Clusters.ServiceArea.Enums.SkipAreaStatus.kInvalidSkippedArea)
153157

154158
if not self.check_pics("SEAR.S.M.VALID_STATE_FOR_SKIP"):
155159
return

0 commit comments

Comments
 (0)