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 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "test_keymap_key.hpp" | 17 | #include "test_keymap_key.hpp" |
| 18 | #include <cstdint> | ||
| 19 | #include <ios> | ||
| 20 | #include "matrix.h" | ||
| 18 | #include "test_logger.hpp" | 21 | #include "test_logger.hpp" |
| 19 | #include "gtest/gtest-message.h" | 22 | #include "gtest/gtest-message.h" |
| 20 | #include "gtest/gtest.h" | 23 | #include "gtest/gtest.h" |
| 24 | #include "timer.h" | ||
| 21 | 25 | ||
| 22 | void KeymapKey::press() { | 26 | void KeymapKey::press() { |
| 23 | test_logger.trace() << "Key pressed: (" << +this->position.col << "," << +this->position.row << ")" << std::endl; | 27 | 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; |
| 28 | |||
| 24 | press_key(this->position.col, this->position.row); | 29 | press_key(this->position.col, this->position.row); |
| 30 | this->timestamp_pressed = timer_read32(); | ||
| 31 | test_logger.trace() << std::setw(10) << std::left << "pressed: " << this->name << std::endl; | ||
| 25 | } | 32 | } |
| 26 | 33 | ||
| 27 | void KeymapKey::release() { | 34 | void KeymapKey::release() { |
| 28 | test_logger.trace() << "Key released: (" << +this->position.col << "," << +this->position.row << ")" << std::endl; | 35 | 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; |
| 36 | |||
| 29 | release_key(this->position.col, this->position.row); | 37 | release_key(this->position.col, this->position.row); |
| 30 | } \ No newline at end of file | 38 | uint32_t now = timer_read32(); |
| 39 | test_logger.trace() << std::setw(10) << std::left << "released: " << this->name << " was pressed for " << now - this->timestamp_pressed << "ms" << std::endl; | ||
| 40 | } | ||
