summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c')
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
index 49716e55c3..4d89e8c0d3 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
@@ -9,6 +9,7 @@
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
+#include "system.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
#include "usb_pd.h"
@@ -205,3 +206,43 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_disconnect_power_info)
"Expected the PD current limit to be >= 0, but got %dmA",
power_info.meas.current_lim);
}
+
+ZTEST(usb_attach_5v_3a_pd_source,
+ test_ap_can_boot_on_low_battery_while_charging)
+{
+ const struct emul *smart_batt_emul = EMUL_DT_GET(DT_NODELABEL(battery));
+ struct sbat_emul_bat_data *batt_data =
+ sbat_emul_get_bat_data(smart_batt_emul);
+
+ /* Set capacity to what gives a charge percentage less than required
+ * for booting the AP
+ *
+ * Capacaity is reset by emulator's ZTEST_RULE
+ */
+ batt_data->cap = (CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON *
+ batt_data->design_cap / 100) -
+ 1;
+
+ zassert_true(system_can_boot_ap(), NULL);
+}
+
+ZTEST_F(usb_attach_5v_3a_pd_source,
+ test_ap_fails_to_boot_on_low_battery_while_not_charging)
+{
+ const struct emul *smart_batt_emul = EMUL_DT_GET(DT_NODELABEL(battery));
+ struct sbat_emul_bat_data *batt_data =
+ sbat_emul_get_bat_data(smart_batt_emul);
+
+ /* Set capacity to what gives a charge percentage less than required
+ * for booting the AP
+ *
+ * Capacaity is reset by emulator's ZTEST_RULE
+ */
+ batt_data->cap = (CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON *
+ batt_data->design_cap / 100) -
+ 1;
+
+ disconnect_source_from_port(fixture->tcpci_emul, fixture->charger_emul);
+
+ zassert_false(system_can_boot_ap(), NULL);
+}