Skip to content

Commit

Permalink
✅ (tests): on device - add more deep sleep core motor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Nov 28, 2022
1 parent 08c84b6 commit e15564b
Showing 1 changed file with 128 additions and 0 deletions.
128 changes: 128 additions & 0 deletions tests/functional/tests/deep_sleep_core_motor/suite_core_motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ suite suite_core_motor = [] {
auto speed = CorePwm {MOTOR_LEFT_PWM};

auto motor = CoreMotor {dir_1, dir_2, speed};
rtos::ThisThread::sleep_for(5ms);

expect(neq(&motor, nullptr));

Expand All @@ -45,4 +46,131 @@ suite suite_core_motor = [] {
};
};
};

scenario("motor spin") = [] {
given("motor is in default configuration") = [] {
auto dir_1 = mbed::DigitalOut {MOTOR_LEFT_DIRECTION_1};
auto dir_2 = mbed::DigitalOut {MOTOR_LEFT_DIRECTION_2};
auto speed = CorePwm {MOTOR_LEFT_PWM};

auto motor = CoreMotor {dir_1, dir_2, speed};

expect(neq(&motor, nullptr));

when("I spin the motor at 50%") = [&] {
motor.spin(Rotation::clockwise, 0.5);

then("I expect deep sleep TO NOT BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(not status.can_deep_sleep);
expect(not status.test_check_ok);
};
};

when("I spin the motor at 100%") = [&] {
motor.spin(Rotation::clockwise, 1.0);

then("I expect deep sleep TO NOT BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(not status.can_deep_sleep);
expect(not status.test_check_ok);
};
};

when("I spin the motor at 0%") = [&] {
motor.spin(Rotation::clockwise, 0.0);
rtos::ThisThread::sleep_for(5ms);

then("I expect deep sleep TO BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(status.can_deep_sleep);
expect(status.test_check_ok);
};
};
};
};

scenario("motor spin, stop, spin, stop") = [] {
given("motor is in default configuration") = [] {
auto dir_1 = mbed::DigitalOut {MOTOR_LEFT_DIRECTION_1};
auto dir_2 = mbed::DigitalOut {MOTOR_LEFT_DIRECTION_2};
auto speed = CorePwm {MOTOR_LEFT_PWM};

auto motor = CoreMotor {dir_1, dir_2, speed};

expect(neq(&motor, nullptr));

when("I spin the motor at 50%") = [&] {
motor.spin(Rotation::clockwise, 0.5);

then("I expect deep sleep TO NOT BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(not status.can_deep_sleep);
expect(not status.test_check_ok);
};
};

when("I stop the motor") = [&] {
motor.stop();
rtos::ThisThread::sleep_for(5ms);

then("I expect deep sleep TO BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(status.can_deep_sleep);
expect(status.test_check_ok);
};
};

when("I spin the motor at 100%") = [&] {
motor.spin(Rotation::clockwise, 1.0);

then("I expect deep sleep TO NOT BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(not status.can_deep_sleep);
expect(not status.test_check_ok);
};
};

when("I stop the motor") = [&] {
motor.stop();
rtos::ThisThread::sleep_for(5ms);

then("I expect deep sleep TO BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(status.can_deep_sleep);
expect(status.test_check_ok);
};
};

when("I spin the motor at 100%") = [&] {
motor.spin(Rotation::clockwise, 1.0);

then("I expect deep sleep TO NOT BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(not status.can_deep_sleep);
expect(not status.test_check_ok);
};
};

when("I spin the motor at 0%") = [&] {
motor.spin(Rotation::clockwise, 0.0);
rtos::ThisThread::sleep_for(5ms);

then("I expect deep sleep TO BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(status.can_deep_sleep);
expect(status.test_check_ok);
};
};
};
};
};

0 comments on commit e15564b

Please sign in to comment.