diff options
author | Tristan Honscheid <honscheid@google.com> | 2022-09-14 13:25:32 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-19 22:49:23 +0000 |
commit | 36fcf3894a2e92bd06ef44ae2a0351a584d4d57b (patch) | |
tree | 62204c8129b3ce03f7a53f5aed718d6ea9fc0d4f | |
parent | 6c7bf3401adf84730ff5f3766f926fc26db8646d (diff) | |
download | chrome-ec-36fcf3894a2e92bd06ef44ae2a0351a584d4d57b.tar.gz |
zephyr: tests: Test host command EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT
Test the EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT host command in
`common/keyboard_backlight.c`
BRANCH=None
BUG=b:246577858
TEST=./twister
Signed-off-by: Tristan Honscheid <honscheid@google.com>
Change-Id: I481d6705aa1e63df4dbf35f12626a53fd5b734b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3892155
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c index 00cf99b7ac..ae186bf84f 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c @@ -47,6 +47,27 @@ ZTEST(keyboard_backlight, host_command_set_backlight__out_of_range) set_backlight_percent_helper(expected_percentage), NULL); } +ZTEST(keyboard_backlight, host_command_get_backlight__normal) +{ + /* Set this backlight intensity and verify via host command */ + uint8_t expected_percentage = 50; + int ret; + + zassume_ok(set_backlight_percent_helper(expected_percentage), NULL); + + /* Brief delay to allow a deferred function to enable the backlight */ + k_sleep(K_MSEC(50)); + + struct ec_response_pwm_get_keyboard_backlight response; + struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE( + EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT, 0, response); + + ret = host_command_process(&args); + zassert_ok(ret, "Host command failed: %d", ret); + zassert_equal(expected_percentage, response.percent, NULL); + zassert_equal(1, response.enabled, "Got 0x%02x", response.enabled); +} + static void reset(void *data) { ARG_UNUSED(data); |