at master 40 lines 1.7 kB view raw
1/* Copyright 2021 Stefan Kerkmann 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17#include "test_keymap_key.hpp" 18#include <cstdint> 19#include <ios> 20#include "matrix.h" 21#include "test_logger.hpp" 22#include "gtest/gtest-message.h" 23#include "gtest/gtest.h" 24#include "timer.h" 25 26void KeymapKey::press() { 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 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; 32} 33 34void KeymapKey::release() { 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 37 release_key(this->position.col, this->position.row); 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}