diff options
Diffstat (limited to 'zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c')
-rw-r--r-- | zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c index 2865d7efc3..149f25dfdd 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c @@ -3,24 +3,17 @@ * found in the LICENSE file. */ -#include "console.h" -#include "host_command.h" -#include "keyboard_backlight.h" -#include "pwm_mock.h" -#include "test/drivers/test_state.h" - #include <stdint.h> #include <string.h> - -#include <zephyr/drivers/pwm.h> +#include <zephyr/ztest.h> #include <zephyr/kernel.h> #include <zephyr/shell/shell_dummy.h> -#include <zephyr/ztest.h> #include <zephyr/ztest_assert.h> -#define KBLIGHT_PWM_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_kblight_pwm) - -extern const struct kblight_drv kblight_pwm; +#include "console.h" +#include "host_command.h" +#include "keyboard_backlight.h" +#include "test/drivers/test_state.h" /** * @brief Send host command to set the backlight percentage @@ -63,7 +56,7 @@ ZTEST(keyboard_backlight, host_command_get_backlight__normal) uint8_t expected_percentage = 50; int ret; - zassert_ok(set_backlight_percent_helper(expected_percentage), NULL); + 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)); @@ -85,7 +78,7 @@ ZTEST(keyboard_backlight, console_command__noargs) const char *outbuffer; size_t buffer_size; - zassert_ok(set_backlight_percent_helper(70), NULL); + zassume_ok(set_backlight_percent_helper(70), NULL); k_sleep(K_MSEC(50)); /* With no args, print current state */ @@ -109,7 +102,7 @@ ZTEST(keyboard_backlight, console_command__set_on) ZTEST(keyboard_backlight, console_command__set_off) { - zassert_ok(set_backlight_percent_helper(40), NULL); + zassume_ok(set_backlight_percent_helper(40), NULL); k_sleep(K_MSEC(50)); /* Turn back off */ @@ -128,26 +121,6 @@ ZTEST(keyboard_backlight, console_command__bad_params) shell_execute_cmd(get_ec_shell(), "kblight 101"), NULL); } -ZTEST(keyboard_backlight, set_backlight__device_not_ready) -{ - const struct pwm_dt_spec kblight_pwm_dt = - PWM_DT_SPEC_GET(KBLIGHT_PWM_NODE); - const struct device *pwm_dev = kblight_pwm_dt.dev; - int initial_duty; - int initialized_saved; - - initial_duty = pwm_mock_get_duty(pwm_dev, kblight_pwm_dt.channel); - - initialized_saved = pwm_dev->state->initialized; - pwm_dev->state->initialized = 0; - - zassert_ok(kblight_pwm.set(initial_duty + 10), NULL); - zassert_equal(initial_duty, - pwm_mock_get_duty(pwm_dev, kblight_pwm_dt.channel), NULL); - - pwm_dev->state->initialized = initialized_saved; -} - static void reset(void *data) { ARG_UNUSED(data); |