diff options
author | Stefan Kerkmann <karlk90@pm.me> | 2022-12-14 16:31:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-15 02:31:08 +1100 |
commit | 962e4c0e1854b10612bab547c3d842c5f967dd23 (patch) | |
tree | dfe13a5a7d3f593452a1e77b5c4173263d3fb2e2 /tests/test_common/test_keymap_key.cpp | |
parent | e2ab98f9601049a7540bd89cb128669b09c688d5 (diff) |
[Test] Reset timer for every unit test and provide timestamps for log messages (#17028)
Diffstat (limited to 'tests/test_common/test_keymap_key.cpp')
-rw-r--r-- | tests/test_common/test_keymap_key.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/test_common/test_keymap_key.cpp b/tests/test_common/test_keymap_key.cpp index 878ae097bf..63ae29975b 100644 --- a/tests/test_common/test_keymap_key.cpp +++ b/tests/test_common/test_keymap_key.cpp @@ -15,16 +15,26 @@ */ #include "test_keymap_key.hpp" +#include <cstdint> +#include <ios> +#include "matrix.h" #include "test_logger.hpp" #include "gtest/gtest-message.h" #include "gtest/gtest.h" +#include "timer.h" void KeymapKey::press() { - test_logger.trace() << "Key pressed: (" << +this->position.col << "," << +this->position.row << ")" << std::endl; + EXPECT_FALSE(matrix_is_on(position.row, position.col)) << "tried to press key " << this->name << " that was already pressed! Check the test code." << std::endl; + press_key(this->position.col, this->position.row); + this->timestamp_pressed = timer_read32(); + test_logger.trace() << std::setw(10) << std::left << "pressed: " << this->name << std::endl; } void KeymapKey::release() { - test_logger.trace() << "Key released: (" << +this->position.col << "," << +this->position.row << ")" << std::endl; + EXPECT_TRUE(matrix_is_on(this->position.row, this->position.col)) << "tried to release key " << this->name << " that wasn't pressed before! Check the test code." << std::endl; + release_key(this->position.col, this->position.row); -}
\ No newline at end of file + uint32_t now = timer_read32(); + test_logger.trace() << std::setw(10) << std::left << "released: " << this->name << " was pressed for " << now - this->timestamp_pressed << "ms" << std::endl; +} |