mirror of
https://github.com/esphome/esphome.git
synced 2026-10-11 05:44:15 +00:00
31 lines
800 B
C++
31 lines
800 B
C++
#ifdef USE_HOST
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "esphome/components/power_supply/power_supply.h"
|
|
#include "esphome/core/gpio.h"
|
|
#include "esphome/core/component.h"
|
|
|
|
namespace esphome::power_supply::testing {
|
|
|
|
TEST(PowerSupply, HasHigherPriorityThanBusWhenInternalAndEnableOnBoot) {
|
|
power_supply::PowerSupply ps;
|
|
InternalGPIOPin pin;
|
|
ps.set_pin(&pin);
|
|
ps.set_enable_on_boot(true);
|
|
|
|
// POWER priority should be greater than BUS priority
|
|
EXPECT_GT(ps.get_setup_priority(), setup_priority::BUS);
|
|
}
|
|
|
|
TEST(PowerSupply, FallsBackToIOWhenNotEnableOnBoot) {
|
|
power_supply::PowerSupply ps;
|
|
InternalGPIOPin pin;
|
|
ps.set_pin(&pin);
|
|
ps.set_enable_on_boot(false);
|
|
|
|
EXPECT_EQ(ps.get_setup_priority(), setup_priority::IO);
|
|
}
|
|
|
|
} // namespace esphome::power_supply::testing
|
|
#endif // USE_HOST
|