clang-format changes
This commit is contained in:
parent
61af76a10d
commit
b624f32f94
502 changed files with 32259 additions and 39062 deletions
|
@ -14,30 +14,29 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
using namespace testing;
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
using namespace testing;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::vector<uint8_t> get_keys(const report_keyboard_t& report) {
|
||||
std::vector<uint8_t> result;
|
||||
#if defined(NKRO_ENABLE)
|
||||
#error NKRO support not implemented yet
|
||||
#elif defined(USB_6KRO_ENABLE)
|
||||
#error 6KRO support not implemented yet
|
||||
#else
|
||||
for(size_t i=0; i<KEYBOARD_REPORT_KEYS; i++) {
|
||||
if (report.keys[i]) {
|
||||
result.emplace_back(report.keys[i]);
|
||||
}
|
||||
namespace {
|
||||
std::vector<uint8_t> get_keys(const report_keyboard_t& report) {
|
||||
std::vector<uint8_t> result;
|
||||
#if defined(NKRO_ENABLE)
|
||||
# error NKRO support not implemented yet
|
||||
#elif defined(USB_6KRO_ENABLE)
|
||||
# error 6KRO support not implemented yet
|
||||
#else
|
||||
for (size_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
|
||||
if (report.keys[i]) {
|
||||
result.emplace_back(report.keys[i]);
|
||||
}
|
||||
#endif
|
||||
std::sort(result.begin(), result.end());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
std::sort(result.begin(), result.end());
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) {
|
||||
auto lhskeys = get_keys(lhs);
|
||||
|
@ -50,7 +49,7 @@ std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) {
|
|||
stream << "Mods: " << (uint32_t)value.mods << std::endl;
|
||||
stream << "Keys: ";
|
||||
// TODO: This should probably print friendly names for the keys
|
||||
for (uint32_t k: get_keys(value)) {
|
||||
for (uint32_t k : get_keys(value)) {
|
||||
stream << k << " ";
|
||||
}
|
||||
stream << std::endl;
|
||||
|
@ -59,24 +58,17 @@ std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) {
|
|||
|
||||
KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) {
|
||||
memset(m_report.raw, 0, sizeof(m_report.raw));
|
||||
for (auto k: keys) {
|
||||
for (auto k : keys) {
|
||||
if (IS_MOD(k)) {
|
||||
m_report.mods |= MOD_BIT(k);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
add_key_to_report(&m_report, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const {
|
||||
return m_report == report;
|
||||
}
|
||||
bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { return m_report == report; }
|
||||
|
||||
void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const {
|
||||
*os << "is equal to " << m_report;
|
||||
}
|
||||
void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { *os << "is equal to " << m_report; }
|
||||
|
||||
void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const {
|
||||
*os << "is not equal to " << m_report;
|
||||
}
|
||||
void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { *os << "is not equal to " << m_report; }
|
|
@ -14,7 +14,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "matrix.h"
|
||||
#include "test_matrix.h"
|
||||
#include <string.h>
|
||||
|
@ -31,33 +30,18 @@ uint8_t matrix_scan(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
matrix_row_t matrix_get_row(uint8_t row) {
|
||||
return matrix[row];
|
||||
}
|
||||
matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; }
|
||||
|
||||
void matrix_print(void) {
|
||||
void matrix_print(void) {}
|
||||
|
||||
}
|
||||
void matrix_init_kb(void) {}
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
void matrix_scan_kb(void) {}
|
||||
|
||||
}
|
||||
void press_key(uint8_t col, uint8_t row) { matrix[row] |= 1 << col; }
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
void release_key(uint8_t col, uint8_t row) { matrix[row] &= ~(1 << col); }
|
||||
|
||||
}
|
||||
void clear_all_keys(void) { memset(matrix, 0, sizeof(matrix)); }
|
||||
|
||||
void press_key(uint8_t col, uint8_t row) {
|
||||
matrix[row] |= 1 << col;
|
||||
}
|
||||
|
||||
void release_key(uint8_t col, uint8_t row) {
|
||||
matrix[row] &= ~(1 << col);
|
||||
}
|
||||
|
||||
void clear_all_keys(void) {
|
||||
memset(matrix, 0, sizeof(matrix));
|
||||
}
|
||||
|
||||
void led_set(uint8_t usb_led) {
|
||||
}
|
||||
void led_set(uint8_t usb_led) {}
|
||||
|
|
|
@ -18,40 +18,19 @@
|
|||
|
||||
TestDriver* TestDriver::m_this = nullptr;
|
||||
|
||||
TestDriver::TestDriver()
|
||||
: m_driver{
|
||||
&TestDriver::keyboard_leds,
|
||||
&TestDriver::send_keyboard,
|
||||
&TestDriver::send_mouse,
|
||||
&TestDriver::send_system,
|
||||
&TestDriver::send_consumer
|
||||
}
|
||||
{
|
||||
TestDriver::TestDriver() : m_driver{&TestDriver::keyboard_leds, &TestDriver::send_keyboard, &TestDriver::send_mouse, &TestDriver::send_system, &TestDriver::send_consumer} {
|
||||
host_set_driver(&m_driver);
|
||||
m_this = this;
|
||||
}
|
||||
|
||||
TestDriver::~TestDriver() {
|
||||
m_this = nullptr;
|
||||
}
|
||||
TestDriver::~TestDriver() { m_this = nullptr; }
|
||||
|
||||
uint8_t TestDriver::keyboard_leds(void) {
|
||||
return m_this->m_leds;
|
||||
}
|
||||
uint8_t TestDriver::keyboard_leds(void) { return m_this->m_leds; }
|
||||
|
||||
void TestDriver::send_keyboard(report_keyboard_t* report) {
|
||||
m_this->send_keyboard_mock(*report);
|
||||
void TestDriver::send_keyboard(report_keyboard_t* report) { m_this->send_keyboard_mock(*report); }
|
||||
|
||||
}
|
||||
void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); }
|
||||
|
||||
void TestDriver::send_mouse(report_mouse_t* report) {
|
||||
m_this->send_mouse_mock(*report);
|
||||
}
|
||||
void TestDriver::send_system(uint16_t data) { m_this->send_system_mock(data); }
|
||||
|
||||
void TestDriver::send_system(uint16_t data) {
|
||||
m_this->send_system_mock(data);
|
||||
}
|
||||
|
||||
void TestDriver::send_consumer(uint16_t data) {
|
||||
m_this->send_consumer(data);
|
||||
}
|
||||
void TestDriver::send_consumer(uint16_t data) { m_this->send_consumer(data); }
|
||||
|
|
|
@ -11,14 +11,14 @@ extern "C" {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
void set_time(uint32_t t);
|
||||
void advance_time(uint32_t ms);
|
||||
void set_time(uint32_t t);
|
||||
void advance_time(uint32_t ms);
|
||||
}
|
||||
|
||||
using testing::_;
|
||||
using testing::AnyNumber;
|
||||
using testing::Return;
|
||||
using testing::Between;
|
||||
using testing::Return;
|
||||
|
||||
void TestFixture::SetUpTestCase() {
|
||||
TestDriver driver;
|
||||
|
@ -26,11 +26,9 @@ void TestFixture::SetUpTestCase() {
|
|||
keyboard_init();
|
||||
}
|
||||
|
||||
void TestFixture::TearDownTestCase() {
|
||||
}
|
||||
void TestFixture::TearDownTestCase() {}
|
||||
|
||||
TestFixture::TestFixture() {
|
||||
}
|
||||
TestFixture::TestFixture() {}
|
||||
|
||||
TestFixture::~TestFixture() {
|
||||
TestDriver driver;
|
||||
|
@ -50,7 +48,7 @@ void TestFixture::run_one_scan_loop() {
|
|||
}
|
||||
|
||||
void TestFixture::idle_for(unsigned time) {
|
||||
for (unsigned i=0; i<time; i++) {
|
||||
for (unsigned i = 0; i < time; i++) {
|
||||
run_one_scan_loop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue