Extension of the unit test of FOptiMove

This commit is contained in:
Markus Gans 2018-07-08 14:48:45 +02:00
parent bdb30c5a96
commit e36a786bc7
8 changed files with 75 additions and 16 deletions

View File

@ -1,3 +1,6 @@
2017-07-08 Markus Gans <guru.mail@muenster.de>
* Extension of the unit test of FOptiMove
2017-07-01 Markus Gans <guru.mail@muenster.de> 2017-07-01 Markus Gans <guru.mail@muenster.de>
* All in FOptiMove required termcap values can now be passed * All in FOptiMove required termcap values can now be passed
with a single struct with a single struct

View File

@ -98,7 +98,8 @@ void move (int xold, int yold, int xnew, int ynew)
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
"BS", "Tab", "LF", "VT", "FF", "CR", "SO", "SI", "BS", "Tab", "LF", "VT", "FF", "CR", "SO", "SI",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
"CAN", "EM", "SUB", "Esc", "FS", "GS", "RS", "US" "CAN", "EM", "SUB", "Esc", "FS", "GS", "RS", "US",
"Space"
}; };
term_boundaries(xold, yold); term_boundaries(xold, yold);
@ -117,7 +118,7 @@ void move (int xold, int yold, int xnew, int ynew)
{ {
char ch = buffer[i]; char ch = buffer[i];
if ( ch < 0x20 ) if ( ch < 0x21 )
sequence += ctrl_character[uInt(ch)]; sequence += ctrl_character[uInt(ch)];
else else
sequence += ch; sequence += ch;

View File

@ -142,8 +142,8 @@ class FApplication : public FWidget
ssize_t readKey(); ssize_t readKey();
FWidget* findKeyboardWidget(); FWidget* findKeyboardWidget();
bool getKeyPressedState(); bool getKeyPressedState();
void keyboardBufferTimeout (FWidget*); void emptyKeyBufferOnTimeout();
void parseKeyPuffer (FWidget*); void parseKeyBuffer (FWidget*);
void performKeyboardAction (FWidget*); void performKeyboardAction (FWidget*);
void sendEscapeKeyPressEvent (FWidget*); void sendEscapeKeyPressEvent (FWidget*);
bool sendKeyDownEvent (FWidget*); bool sendKeyDownEvent (FWidget*);

View File

@ -38,7 +38,6 @@
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "final/fterm.h"
#include "final/ftypes.h" #include "final/ftypes.h"

View File

@ -566,10 +566,10 @@ inline bool FApplication::getKeyPressedState()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::keyboardBufferTimeout (FWidget*) inline void FApplication::emptyKeyBufferOnTimeout()
{ {
// Empty the buffer on timeout // Empty the buffer on timeout
if ( fifo_in_use && isKeypressTimeout(&time_keypressed) ) if ( fifo_in_use && isKeypressTimeout(&time_keypressed) )
{ {
fifo_offset = 0; fifo_offset = 0;
key = 0; key = 0;
@ -579,7 +579,7 @@ inline void FApplication::keyboardBufferTimeout (FWidget*)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::parseKeyPuffer (FWidget* widget) inline void FApplication::parseKeyBuffer (FWidget* widget)
{ {
register ssize_t bytesread; register ssize_t bytesread;
getCurrentTime (&time_keypressed); getCurrentTime (&time_keypressed);
@ -746,12 +746,12 @@ inline void FApplication::sendKeyboardAccelerator()
void FApplication::processKeyboardEvent() void FApplication::processKeyboardEvent()
{ {
FWidget* widget = findKeyboardWidget(); FWidget* widget = findKeyboardWidget();
keyboardBufferTimeout(widget); emptyKeyBufferOnTimeout();
flush_out(); flush_out();
bool isKeyPressed = getKeyPressedState(); bool isKeyPressed = getKeyPressedState();
if ( isKeyPressed ) if ( isKeyPressed )
parseKeyPuffer (widget); parseKeyBuffer (widget);
// special case: Esc key // special case: Esc key
sendEscapeKeyPressEvent (widget); sendEscapeKeyPressEvent (widget);

View File

@ -262,12 +262,11 @@ int FTerm::parseKeyString ( char buffer[]
, int buf_size , int buf_size
, timeval* time_keypressed ) , timeval* time_keypressed )
{ {
int key;
uChar firstchar = uChar(buffer[0]); uChar firstchar = uChar(buffer[0]);
if ( firstchar == ESC[0] ) if ( firstchar == ESC[0] )
{ {
key = getMouseProtocolKey(buffer); int key = getMouseProtocolKey(buffer);
if ( key > 0 ) if ( key > 0 )
return key; return key;

View File

@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include "final/ftermios.h" #include "final/ftermios.h"
#include "final/fterm.h"
// static class attributes // static class attributes
int FTermios::stdin_no; int FTermios::stdin_no;

View File

@ -79,6 +79,7 @@ class FOptiMoveTest : public CPPUNIT_NS::TestFixture
void cygwinTest(); void cygwinTest();
void puttyTest(); void puttyTest();
void teratermTest(); void teratermTest();
void wyse50Test();
private: private:
std::string printSequence (const std::string&); std::string printSequence (const std::string&);
@ -99,6 +100,7 @@ class FOptiMoveTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST (cygwinTest); CPPUNIT_TEST (cygwinTest);
CPPUNIT_TEST (puttyTest); CPPUNIT_TEST (puttyTest);
CPPUNIT_TEST (teratermTest); CPPUNIT_TEST (teratermTest);
CPPUNIT_TEST (wyse50Test);
// End of test suite definition // End of test suite definition
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
@ -638,10 +640,6 @@ void FOptiMoveTest::teratermTest()
om.setTermEnvironment(optimove_env); om.setTermEnvironment(optimove_env);
//std::cout << "\nSequence: "
// << printSequence(om.moveCursor (1, 2, 3, 4))
// << "\n";
CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), C_STR(CSI "6;6H")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), C_STR(CSI "6;6H"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), C_STR(CSI "H")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), C_STR(CSI "H"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 1), C_STR("\r")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 1), C_STR("\r"));
@ -677,6 +675,64 @@ void FOptiMoveTest::teratermTest()
CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 2, 53, -3), C_STR(CSI "1d")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 2, 53, -3), C_STR(CSI "1d"));
} }
//----------------------------------------------------------------------
void FOptiMoveTest::wyse50Test()
{
FOptiMove om;
om.setTermSize (80, 25);
om.setBaudRate (38400);
om.set_auto_left_margin (true);
om.set_tabular (C_STR("\t"));
om.set_back_tab (C_STR(ESC "I"));
om.set_cursor_home (C_STR("\036"));
om.set_cursor_to_ll (C_STR("\036\v"));
om.set_carriage_return (C_STR("\r"));
om.set_cursor_up (C_STR("\v"));
om.set_cursor_down (C_STR("\n"));
om.set_cursor_right (C_STR("\f"));
om.set_cursor_left (C_STR("\b"));
om.set_cursor_address (C_STR(ESC "=%p1%' '%+%c%p2%' '%+%c"));
//std::cout << "\nSequence: "
// << printSequence(om.moveCursor (1, 2, 3, 4))
// << "\n";
CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), C_STR(ESC "=%%"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), C_STR("\036"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 1), C_STR("\r"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 2), C_STR("\r\n"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 10, 4), C_STR("\f"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 4, 9, 4), C_STR("\b"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 11, 4), C_STR("\f\f"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (11, 4, 9, 4), C_STR("\b\b"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (1, 0, 8, 0), C_STR(ESC "= ("));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 0, 16, 1), C_STR("\n"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 1, 16, 0), C_STR("\v"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 0, 16, 2), C_STR("\n\n"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 2, 16, 0), C_STR("\v\v"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (3, 2, 79, 2), C_STR("\r\b\n"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 75, 20), C_STR(ESC "=4k"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (39, 0, 32, 0), C_STR(ESC "= @"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 0, 8, 0), C_STR("\b\b"));
// xold is outside screen
CPPUNIT_ASSERT_CSTRING (om.moveCursor (99, 10, 79, 10), C_STR(ESC "=*o"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (-3, 33, 50, 10), C_STR(ESC "=*R"));
// ynew is outside screen
CPPUNIT_ASSERT_CSTRING (om.moveCursor (23, 33, 23, 10), C_STR(ESC "=*7"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (23, -3, 12, 10), C_STR(ESC "=*,"));
// xnew is outside screen
CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 22, 100, 22), C_STR("\r\b\n"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (3, 22, -5, 22), C_STR("\r"));
// ynew is outside screen
CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 23, 53, 40), C_STR("\n"));
CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 2, 53, -3), C_STR("\v\v"));
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::string FOptiMoveTest::printSequence (const std::string& s) std::string FOptiMoveTest::printSequence (const std::string& s)
{ {