Skip to content

Commit

Permalink
Fix tests and failures found by tests in holiday schedules for the do…
Browse files Browse the repository at this point in the history
…or lock
  • Loading branch information
Morozov-5F committed May 23, 2022
1 parent 429b3af commit 36f4d2d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 51 deletions.
23 changes: 17 additions & 6 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ void DoorLockServer::sendHolidayScheduleResponse(chip::app::CommandHandler * com
{
VerifyOrDie(nullptr != commandObj);

auto response = Commands::GetHolidayScheduleResponse::Type{ holidayIndex, DlStatus::kSuccess };
auto response = Commands::GetHolidayScheduleResponse::Type{ holidayIndex, status };
if (DlStatus::kSuccess == status)
{
response.localStartTime = Optional<uint32_t>(localStartTime);
Expand Down Expand Up @@ -2740,6 +2740,16 @@ void DoorLockServer::setHolidaySchedule(chip::app::CommandHandler * commandObj,
return;
}

if (operatingMode > DlOperatingMode::kPassage)
{
emberAfDoorLockClusterPrintln("[SetHolidaySchedule] Unable to add schedule - operating mode is out of range"
"[endpointId=%d,scheduleIndex=%d,localStarTime=%" PRIu32 ",localEndTime=%" PRIu32
", operatingMode=%d]",
endpointId, holidayIndex, localStartTime, localEndTime, to_underlying(operatingMode));
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_FIELD);
return;
}

auto status = emberAfPluginDoorLockSetSchedule(endpointId, holidayIndex, DlScheduleStatus::kOccupied, localStartTime,
localEndTime, operatingMode);
if (DlStatus::kSuccess != status)
Expand All @@ -2751,8 +2761,9 @@ void DoorLockServer::setHolidaySchedule(chip::app::CommandHandler * commandObj,
}

emberAfDoorLockClusterPrintln("[SetHolidaySchedule] Successfully created new schedule "
"[endpointId=%d,scheduleIndex=%d,localStartTime=%" PRIu32 ",endTime=%" PRIu32 "]",
endpointId, holidayIndex, localStartTime, localEndTime);
"[endpointId=%d,scheduleIndex=%d,localStartTime=%" PRIu32 ",endTime=%" PRIu32
",operatingMode=%d]",
endpointId, holidayIndex, localStartTime, localEndTime, to_underlying(operatingMode));

emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS);
}
Expand Down Expand Up @@ -2788,7 +2799,7 @@ void DoorLockServer::getHolidaySchedule(chip::app::CommandHandler * commandObj,
return;
}
sendHolidayScheduleResponse(commandObj, commandPath, holidayIndex, DlStatus::kSuccess, scheduleInfo.localStartTime,
scheduleInfo.localEndTime);
scheduleInfo.localEndTime, scheduleInfo.operatingMode);
}

void DoorLockServer::clearHolidaySchedule(chip::app::CommandHandler * commandObj,
Expand Down Expand Up @@ -3446,8 +3457,8 @@ DlStatus __attribute__((weak)) emberAfPluginDoorLockGetSchedule(chip::EndpointId
return DlStatus::kFailure;
}

DlStatus __attribute__((weak)) emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex,
EmberAfPluginDoorLockHolidaySchedule & schedule)
DlStatus __attribute__((weak))
emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule)
{
return DlStatus::kFailure;
}
Expand Down
62 changes: 17 additions & 45 deletions src/app/tests/suites/DL_Schedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -771,28 +771,24 @@ tests:
command: "GetHolidaySchedule"
arguments:
values:
- name: "yearDayIndex"
- name: "holidayIndex"
value: 0
- name: "userIndex"
value: 1
response:
values:
- name: "yearDayIndex"
- name: "holidayIndex"
value: 0
- name: "userIndex"
value: 1
- name: "status"
value: 0x85

- label: "Get Holiday schedule with out-of-bounds index"
command: "GetHolidaySchedule"
arguments:
values:
- name: "yearDayIndex"
- name: "holidayIndex"
value: NumberOfHolidaySchedulesSupported + 1
response:
values:
- name: "yearDayIndex"
- name: "holidayIndex"
value: NumberOfHolidaySchedulesSupported + 1
- name: "status"
value: 0x85
Expand Down Expand Up @@ -1988,13 +1984,13 @@ tests:

# Start clearing holiday schedules
- label: "Clear a single holiday schedule"
command: "ClearYearDaySchedule"
command: "ClearHolidaySchedule"
arguments:
values:
- name: "holidayIndex"
value: 2

- label: "Make sure that first holiday schedule was deleted"
- label: "Make sure that first holiday schedule was not deleted"
command: "GetHolidaySchedule"
arguments:
values:
Expand All @@ -2005,15 +2001,15 @@ tests:
- name: "holidayIndex"
value: 1
- name: "status"
value: 0x8B
value: 0x0
- name: "localStartTime"
value: null
value: 12345
- name: "localEndTime"
value: null
value: 12345689
- name: "operatingMode"
value: null
value: 0

- label: "Make sure that second holiday schedule was not deleted"
- label: "Make sure that second holiday schedule was deleted"
command: "GetHolidaySchedule"
arguments:
values:
Expand All @@ -2024,13 +2020,7 @@ tests:
- name: "holidayIndex"
value: 2
- name: "status"
value: 0x0
- name: "localStartTime"
value: 123456
- name: "localEndTime"
value: 1234567
- name: "operatingMode"
value: 1
value: 0x8B

- label: "Make sure that third holiday schedule was not deleted"
command: "GetHolidaySchedule"
Expand All @@ -2057,9 +2047,9 @@ tests:
arguments:
values:
- name: "weekDayIndex"
value: 4
value: 1
- name: "userIndex"
value: 2
value: 1
response:
values:
- name: "weekDayIndex"
Expand Down Expand Up @@ -2102,7 +2092,7 @@ tests:
value: 888888888

- label: "Clear all remaining holiday schedules"
command: "ClearYearDaySchedule"
command: "ClearHolidaySchedule"
arguments:
values:
- name: "holidayIndex"
Expand All @@ -2120,12 +2110,6 @@ tests:
value: 1
- name: "status"
value: 0x8B
- name: "localStartTime"
value: null
- name: "localEndTime"
value: null
- name: "operatingMode"
value: null

- label: "Make sure that second holiday schedule was deleted"
command: "GetHolidaySchedule"
Expand All @@ -2139,12 +2123,6 @@ tests:
value: 2
- name: "status"
value: 0x8B
- name: "localStartTime"
value: null
- name: "localEndTime"
value: null
- name: "operatingMode"
value: null

- label: "Make sure that third holiday schedule was not deleted"
command: "GetHolidaySchedule"
Expand All @@ -2158,22 +2136,16 @@ tests:
value: NumberOfHolidaySchedulesSupported
- name: "status"
value: 0x8B
- name: "localStartTime"
value: null
- name: "localEndTime"
value: null
- name: "operatingMode"
value: null

- label:
"Make sure clearing holiday schedule did not clear week day schedule"
command: "GetWeekDaySchedule"
arguments:
values:
- name: "weekDayIndex"
value: 4
value: 1
- name: "userIndex"
value: 2
value: 1
response:
values:
- name: "weekDayIndex"
Expand Down
8 changes: 8 additions & 0 deletions src/app/tests/suites/DL_UsersAndCredentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2517,3 +2517,11 @@ tests:
value: null
- name: "nextCredentialIndex"
value: 7

- label: "Final clean-up"
command: "ClearUser"
timedInteractionTimeoutMs: 10000
arguments:
values:
- name: "userIndex"
value: 1

0 comments on commit 36f4d2d

Please sign in to comment.