From 885993c3bd7e13a428b4d7524ff562d272df57b3 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 23 Jul 2018 01:48:29 +0200 Subject: [PATCH] FKeyboardTest fixes --- src/fkeyboard.cpp | 5 +++- src/test/fkeyboard-test.cpp | 51 ++++++++++++++++++++++--------------- src/test/foptiattr-test.cpp | 4 +-- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 62048138..594b835b 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -501,7 +501,10 @@ int FKeyboard::keyCorrection (const int& keycode) int key_correction; #if defined(__linux__) - key_correction = linux->modifierKeyCorrection(keycode); + if ( linux ) + key_correction = linux->modifierKeyCorrection(keycode); + else + key_correction = key; #else key_correction = key; #endif diff --git a/src/test/fkeyboard-test.cpp b/src/test/fkeyboard-test.cpp index 7c0a551a..e892a8a5 100644 --- a/src/test/fkeyboard-test.cpp +++ b/src/test/fkeyboard-test.cpp @@ -244,6 +244,7 @@ class FKeyboardTest : public CPPUNIT_NS::TestFixture // End of test suite definition CPPUNIT_TEST_SUITE_END(); + void init(); void input (std::string); void processInput(); void clear(); @@ -264,24 +265,7 @@ FKeyboardTest::FKeyboardTest() , key_released(0) , keyboard(0) { - keyboard = new FKeyboard(); - FApplication* object = reinterpret_cast(this); - void (FApplication::*method1)() - = reinterpret_cast(&FKeyboardTest::keyPressed); - void (FApplication::*method2)() - = reinterpret_cast(&FKeyboardTest::keyReleased); - void (FApplication::*method3)() - = reinterpret_cast(&FKeyboardTest::escapeKeyPressed); - FKeyboardCommand key_cmd1 (object, method1); - FKeyboardCommand key_cmd2 (object, method2); - FKeyboardCommand key_cmd3 (object, method3); - keyboard->setPressCommand (key_cmd1); - keyboard->setReleaseCommand (key_cmd2); - keyboard->setEscPressedCommand (key_cmd3); - keyboard->setKeypressTimeout (100000); // 100 ms - keyboard->enableUTF8(); - keyboard->enableMouseSequences(); - keyboard->setTermcapMap (reinterpret_cast(test::Fkey)); + init(); } //---------------------------------------------------------------------- @@ -389,6 +373,29 @@ void FKeyboardTest::inputTest() clear(); } +//---------------------------------------------------------------------- +void FKeyboardTest::init() +{ + keyboard = new FKeyboard(); + FApplication* object = reinterpret_cast(this); + void (FApplication::*method1)() + = reinterpret_cast(&FKeyboardTest::keyPressed); + void (FApplication::*method2)() + = reinterpret_cast(&FKeyboardTest::keyReleased); + void (FApplication::*method3)() + = reinterpret_cast(&FKeyboardTest::escapeKeyPressed); + FKeyboardCommand key_cmd1 (object, method1); + FKeyboardCommand key_cmd2 (object, method2); + FKeyboardCommand key_cmd3 (object, method3); + keyboard->setPressCommand (key_cmd1); + keyboard->setReleaseCommand (key_cmd2); + keyboard->setEscPressedCommand (key_cmd3); + keyboard->setKeypressTimeout (100000); // 100 ms + keyboard->enableUTF8(); + keyboard->enableMouseSequences(); + keyboard->setTermcapMap (reinterpret_cast(test::Fkey)); +} + //---------------------------------------------------------------------- void FKeyboardTest::input (std::string s) { @@ -402,11 +409,15 @@ void FKeyboardTest::input (std::string s) while ( iter != s.end() ) { char c = *iter; - ioctl (FTermios::getStdIn(), TIOCSTI, &c); + + if ( ioctl (FTermios::getStdIn(), TIOCSTI, &c) < 0 ) + break; + ++iter; } - ioctl (FTermios::getStdIn(), TIOCSTI, &EOT); + if ( ioctl (FTermios::getStdIn(), TIOCSTI, &EOT) < 0 ) + return; } //---------------------------------------------------------------------- diff --git a/src/test/foptiattr-test.cpp b/src/test/foptiattr-test.cpp index b954b429..815838be 100644 --- a/src/test/foptiattr-test.cpp +++ b/src/test/foptiattr-test.cpp @@ -4035,8 +4035,8 @@ void FOptiAttrTest::wyse50Test() ESC "G0" ESC "cD"), // Exit crossed out 0, // Enter double underline 0, // Exit double underline - C_STR("%?%p8%t\E)%e\E(%;" - "%?%p9%t\EcE%e\EcD%;\EG%'0'" + C_STR("%?%p8%t\033)%e\033(%;" + "%?%p9%t\033cE%e\033cD%;\033G%'0'" "%?%p2%t%{8}%|%;" "%?%p1%p3%|%p6%|%t%{4}%|%;" "%?%p4%t%{2}%|%;"