Expanding the unit test for FTermLinux

This commit is contained in:
Markus Gans 2019-07-04 15:26:26 +02:00
parent 340d78e433
commit 38df039235
8 changed files with 561 additions and 90 deletions

View File

@ -1,5 +1,5 @@
2019-06-30 Markus Gans <guru.mail@muenster.de> 2019-06-30 Markus Gans <guru.mail@muenster.de>
* Expanding the Unit Test for FTermLinux * Expanding the unit test for FTermLinux
* Update the cp437 unicode map * Update the cp437 unicode map
* Reducing the special cases for Solaris * Reducing the special cases for Solaris

View File

@ -152,47 +152,53 @@ Class digramm
1┌──────────────┐ 1┌──────────────┐
┌-----------┤ FTermFreeBSD │ ┌-----------┤ FTermFreeBSD │
: └──────────────┘ : └──────────────┘
: 1┌──────────────┐ ┌───────────┐ : 1┌──────────────┐
┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │ ┌-----------┤ FTermOpenBSD │
: └──────────────┘ │ └───────────┘ : └──────────────┘
: 1┌────────────────┐ ┌───────────┐
┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │
: └────────────────┘ │ └───────────┘
: 1┌────────────────┐ │ ┌─────────────┐ : 1┌────────────────┐ │ ┌─────────────┐
┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │ ┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │
: └────────────────┘ │ └─────────────┘ : └────────────────┘ │ └─────────────┘
: 1┌────────────────┐ │ ┌─────────────┐ : 1┌────────────────┐ │ ┌─────────────┐
┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │ ┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │
: └────────────────┘ │ └─────────────┘
: 1┌────────────────┐ │ ┌─────────────┐
┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │
: └────────────────┘ │ └─────────────┘ : └────────────────┘ │ └─────────────┘
: 1┌──────────┐ │ ┌─────────────┐ : 1┌──────────┐ │ ┌─────────────┐
┌-----------┤ FTermcap │ ├────┤ FAccelEvent │ ┌-----------┤ FTermcap │ ├────┤ FFocusEvent │
: └──────────┘ │ └─────────────┘ : └──────────┘ │ └─────────────┘
: 1┌──────────┐ │ ┌───────────── : 1┌──────────┐ │ ┌─────────────┐
┌-----------┤ FTermios │ ├────┤ FResizeEvent │ ┌-----------┤ FTermios │ ├────┤ FAccelEvent │
: └──────────┘ │ └───────────── : └──────────┘ │ └─────────────┘
: 1┌───────────────┐ │ ┌────────────┐ : 1┌───────────────┐ │ ┌──────────────
┌-----------┤ FColorPalette │ ├────┤ FShowEvent │ ┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │
: └───────────────┘ │ └────────────┘ : └───────────────┘ │ └──────────────
: 1┌───────────┐ │ ┌────────────┐ : 1┌───────────┐ │ ┌────────────┐
┌-----------┤ FOptiMove │ ├────┤ FHideEvent │ ┌-----------┤ FOptiMove │ ├────┤ FShowEvent │
: └───────────┘ │ └────────────┘
: 1┌───────────┐ │ ┌────────────┐
┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │
: └───────────┘ │ └────────────┘ : └───────────┘ │ └────────────┘
: 1┌───────────┐ │ ┌─────────────┐ : 1┌───────────┐ │ ┌─────────────┐
┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │ ┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │
: └───────────┘ │ └─────────────┘ : └───────────┘ │ └─────────────┘
: 1┌───────────┐ │ ┌─────────────┐ : 1┌───────────────┐ │ ┌─────────────┐
┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │ ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
: └───────────┘ │ └─────────────┘ : └───────────────┘ │ └─────────────┘
: 1┌───────────────┐ │ : 1┌─────────┐ │
┌-----------┤ FMouseControl │ │ ┌──────────────┐ ┌-----------┤ FSystem │ │
: └───────────────┘ │ ┌────┤ FApplication │ : └─────────┘ │
: *┌─────────┐ │ │ └──────────────┘ : *┌─────────┐ │
: ┌--------┤ FString │ │ │ ┌─────────┐ : ┌--------┤ FString │ │ ┌──────────────┐
: : └─────────┘ │ ├────┤ FButton │ : : └─────────┘ │ ┌────┤ FApplication │
: : *┌────────┐ │ │ └─────────┘ : : *┌────────┐ │ │ └──────────────┘
: ┌--------┤ FPoint │ │ │ ┌────────┐ : ┌--------┤ FPoint │ │ │ ┌─────────┐
: : └────────┘ │ ├────┤ FLabel │ : : └────────┘ │ ├────┤ FButton │
: : *┌───────┐ │ │ └─────────┘
: ┌--------┤ FRect │ │ │ ┌────────┐
: : └───────┘ │ ├────┤ FLabel │
: : *┌───────┐ │ │ └────────┘ : : *┌───────┐ │ │ └────────┘
: ┌--------┤ FRect │ │ │ ┌───────────┐ : ┌--------┤ FSize │ │ │ ┌───────────┐
: : └───────┘ │ ├────┤ FLineEdit │ : : └───────┘ │ ├────┤ FLineEdit │
:1 :1 │ │ └───────────┘ :1 :1 │ │ └───────────┘
┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐ ┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐

View File

@ -139,6 +139,7 @@ if [ "$1" = "--unit-test" ] \
|| [ "$1" = "--coverage" ] \ || [ "$1" = "--coverage" ] \
|| [ "$1" = "coverage" ] || [ "$1" = "coverage" ]
then then
rm test/*.log 2>/dev/null
cd test && make check-TESTS cd test && make check-TESTS
cat ./*.log 2>/dev/null cat ./*.log 2>/dev/null
cd .. || exit cd .. || exit

View File

@ -4,47 +4,53 @@
1┌──────────────┐ 1┌──────────────┐
┌-----------┤ FTermFreeBSD │ ┌-----------┤ FTermFreeBSD │
: └──────────────┘ : └──────────────┘
: 1┌──────────────┐ ┌───────────┐ : 1┌──────────────┐
┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │ ┌-----------┤ FTermOpenBSD │
: └──────────────┘ │ └───────────┘ : └──────────────┘
: 1┌────────────────┐ ┌───────────┐
┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │
: └────────────────┘ │ └───────────┘
: 1┌────────────────┐ │ ┌─────────────┐ : 1┌────────────────┐ │ ┌─────────────┐
┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │ ┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │
: └────────────────┘ │ └─────────────┘ : └────────────────┘ │ └─────────────┘
: 1┌────────────────┐ │ ┌─────────────┐ : 1┌────────────────┐ │ ┌─────────────┐
┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │ ┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │
: └────────────────┘ │ └─────────────┘
: 1┌────────────────┐ │ ┌─────────────┐
┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │
: └────────────────┘ │ └─────────────┘ : └────────────────┘ │ └─────────────┘
: 1┌──────────┐ │ ┌─────────────┐ : 1┌──────────┐ │ ┌─────────────┐
┌-----------┤ FTermcap │ ├────┤ FAccelEvent │ ┌-----------┤ FTermcap │ ├────┤ FFocusEvent │
: └──────────┘ │ └─────────────┘ : └──────────┘ │ └─────────────┘
: 1┌──────────┐ │ ┌───────────── : 1┌──────────┐ │ ┌─────────────┐
┌-----------┤ FTermios │ ├────┤ FResizeEvent │ ┌-----------┤ FTermios │ ├────┤ FAccelEvent │
: └──────────┘ │ └───────────── : └──────────┘ │ └─────────────┘
: 1┌───────────────┐ │ ┌────────────┐ : 1┌───────────────┐ │ ┌──────────────
┌-----------┤ FColorPalette │ ├────┤ FShowEvent │ ┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │
: └───────────────┘ │ └────────────┘ : └───────────────┘ │ └──────────────
: 1┌───────────┐ │ ┌────────────┐ : 1┌───────────┐ │ ┌────────────┐
┌-----------┤ FOptiMove │ ├────┤ FHideEvent │ ┌-----------┤ FOptiMove │ ├────┤ FShowEvent │
: └───────────┘ │ └────────────┘
: 1┌───────────┐ │ ┌────────────┐
┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │
: └───────────┘ │ └────────────┘ : └───────────┘ │ └────────────┘
: 1┌───────────┐ │ ┌─────────────┐ : 1┌───────────┐ │ ┌─────────────┐
┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │ ┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │
: └───────────┘ │ └─────────────┘ : └───────────┘ │ └─────────────┘
: 1┌───────────┐ │ ┌─────────────┐ : 1┌───────────────┐ │ ┌─────────────┐
┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │ ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
: └───────────┘ │ └─────────────┘ : └───────────────┘ │ └─────────────┘
: 1┌───────────────┐ │ : 1┌─────────┐ │
┌-----------┤ FMouseControl │ │ ┌──────────────┐ ┌-----------┤ FSystem │ │
: └───────────────┘ │ ┌────┤ FApplication │ : └─────────┘ │
: *┌─────────┐ │ │ └──────────────┘ : *┌─────────┐ │
: ┌--------┤ FString │ │ │ ┌─────────┐ : ┌--------┤ FString │ │ ┌──────────────┐
: : └─────────┘ │ ├────┤ FButton │ : : └─────────┘ │ ┌────┤ FApplication │
: : *┌────────┐ │ │ └─────────┘ : : *┌────────┐ │ │ └──────────────┘
: ┌--------┤ FPoint │ │ │ ┌────────┐ : ┌--------┤ FPoint │ │ │ ┌─────────┐
: : └────────┘ │ ├────┤ FLabel │ : : └────────┘ │ ├────┤ FButton │
: : *┌───────┐ │ │ └─────────┘
: ┌--------┤ FRect │ │ │ ┌────────┐
: : └───────┘ │ ├────┤ FLabel │
: : *┌───────┐ │ │ └────────┘ : : *┌───────┐ │ │ └────────┘
: ┌--------┤ FRect │ │ │ ┌───────────┐ : ┌--------┤ FSize │ │ │ ┌───────────┐
: : └───────┘ │ ├────┤ FLineEdit │ : : └───────┘ │ ├────┤ FLineEdit │
:1 :1 │ │ └───────────┘ :1 :1 │ │ └───────────┘
┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐ ┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐
@ -100,4 +106,3 @@
└──────────┘ │ ┌────────────────┐* : └──────────┘ │ ┌────────────────┐* :
└──┤ FRadioMenuItem ├---┘ └──┤ FRadioMenuItem ├---┘
└────────────────┘ └────────────────┘

View File

@ -252,6 +252,7 @@ void FTermLinux::finish()
bool FTermLinux::loadVGAFont() bool FTermLinux::loadVGAFont()
{ {
vga_font = true; vga_font = true;
new_font = false;
if ( FTerm::openConsole() == 0 ) if ( FTerm::openConsole() == 0 )
{ {
@ -292,6 +293,7 @@ bool FTermLinux::loadVGAFont()
bool FTermLinux::loadNewFont() bool FTermLinux::loadNewFont()
{ {
new_font = true; new_font = true;
vga_font = false;
if ( FTerm::openConsole() == 0 ) if ( FTerm::openConsole() == 0 )
{ {
@ -840,7 +842,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable)
if ( screen_font.charcount > 256 ) if ( screen_font.charcount > 256 )
return -1; return -1;
if ( getuid() != 0 ) // Direct hardware access requires root privileges if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges
return -2; return -2;
if ( fd_tty < 0 ) if ( fd_tty < 0 )
@ -1109,10 +1111,10 @@ FKey FTermLinux::shiftAltKeyCorrection (const FKey& key_id)
return fc::Fmkey_sdown; // Shift+Meta+Down return fc::Fmkey_sdown; // Shift+Meta+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fmkey_sright; // Shift+Meta+Left return fc::Fmkey_sleft; // Shift+Meta+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fmkey_sleft; // Shift+Meta+Right return fc::Fmkey_sright; // Shift+Meta+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fmkey_sic; // Shift+Meta+Ins return fc::Fmkey_sic; // Shift+Meta+Ins

View File

@ -58,15 +58,16 @@ class FSystem
// Methods // Methods
virtual uChar inPortByte (uShort) = 0; virtual uChar inPortByte (uShort) = 0;
virtual void outPortByte (uChar, uShort) = 0; virtual void outPortByte (uChar, uShort) = 0;
virtual int isTTY (int) = 0; virtual int isTTY (int) = 0;
virtual int ioctl (int, uLong, ...) = 0; virtual int ioctl (int, uLong, ...) = 0;
virtual int open (const char*, int, ...) = 0; virtual int open (const char*, int, ...) = 0;
virtual int close (int) = 0; virtual int close (int) = 0;
virtual FILE* fopen (const char*, const char*) = 0; virtual FILE* fopen (const char*, const char*) = 0;
virtual int fclose (FILE*) = 0; virtual int fclose (FILE*) = 0;
virtual int putchar (int) = 0; virtual int putchar (int) = 0;
virtual int tputs (const char*, int, int (*)(int)) = 0; virtual int tputs (const char*, int, int (*)(int)) = 0;
virtual uid_t getuid() = 0;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -186,6 +186,10 @@ class FSystemImpl : public FSystem
#endif #endif
} }
virtual uid_t getuid()
{
return ::getuid();
}
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -114,11 +114,11 @@ class FSystemTest : public finalcut::FSystem
virtual int fclose (FILE*); virtual int fclose (FILE*);
virtual int putchar (int); virtual int putchar (int);
virtual int tputs (const char*, int, int (*)(int)); virtual int tputs (const char*, int, int (*)(int));
virtual uid_t getuid();
rgb& getRGB (std::size_t); rgb& getRGB (std::size_t);
console_font_op& getConsoleFont(); console_font_op& getConsoleFont();
shiftstate& getShiftState();
// Data Members std::string& getCharacters();
std::string characters;
private: private:
// Methods // Methods
@ -126,6 +126,7 @@ class FSystemTest : public finalcut::FSystem
static void initFScreenInfo(); static void initFScreenInfo();
// Data Members // Data Members
std::string characters;
static shiftstate shift_state; static shiftstate shift_state;
static rgb terminal_color[16]; static rgb terminal_color[16];
static rgb defaultColor[16]; static rgb defaultColor[16];
@ -148,7 +149,6 @@ class FSystemTest : public finalcut::FSystem
uChar port_3da = 0; // Input status 1 uChar port_3da = 0; // Input status 1
static uChar vga8x16[]; static uChar vga8x16[];
static struct unipair unicode_cp437_pairs[]; static struct unipair unicode_cp437_pairs[];
}; };
#pragma pack(pop) #pragma pack(pop)
@ -1341,6 +1341,12 @@ int FSystemTest::tputs (const char* str, int affcnt, int (*putc)(int))
return ::tputs (str, affcnt, putc); return ::tputs (str, affcnt, putc);
} }
//----------------------------------------------------------------------
uid_t FSystemTest::getuid()
{
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FSystemTest::rgb& FSystemTest::getRGB (std::size_t i) FSystemTest::rgb& FSystemTest::getRGB (std::size_t i)
{ {
@ -1356,6 +1362,17 @@ console_font_op& FSystemTest::getConsoleFont()
return terminal_font; return terminal_font;
} }
//----------------------------------------------------------------------
FSystemTest::shiftstate& FSystemTest::getShiftState()
{
return shift_state;
}
//----------------------------------------------------------------------
std::string& FSystemTest::getCharacters()
{
return characters;
}
// private methods of FSystemTest // private methods of FSystemTest
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1450,6 +1467,7 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu
void linuxCursorStyleTest(); void linuxCursorStyleTest();
void linuxColorPaletteTest(); void linuxColorPaletteTest();
void linuxFontTest(); void linuxFontTest();
void modifierKeyTest();
private: private:
// Adds code needed to register the test suite // Adds code needed to register the test suite
@ -1461,6 +1479,7 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu
CPPUNIT_TEST (linuxCursorStyleTest); CPPUNIT_TEST (linuxCursorStyleTest);
CPPUNIT_TEST (linuxColorPaletteTest); CPPUNIT_TEST (linuxColorPaletteTest);
CPPUNIT_TEST (linuxFontTest); CPPUNIT_TEST (linuxFontTest);
CPPUNIT_TEST (modifierKeyTest);
// End of test suite definition // End of test suite definition
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
@ -1556,21 +1575,22 @@ void FTermLinuxTest::linuxConsoleTest()
CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 ); CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 );
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys);
std::string& characters = fsystest->getCharacters();
linux.setUTF8 (false); linux.setUTF8 (false);
CPPUNIT_ASSERT ( fsystest->characters == ESC "%@" ); CPPUNIT_ASSERT ( characters == ESC "%@" );
fsystest->characters.clear(); characters.clear();
linux.setUTF8 (true); linux.setUTF8 (true);
CPPUNIT_ASSERT ( fsystest->characters == ESC "%G" ); CPPUNIT_ASSERT ( characters == ESC "%G" );
fsystest->characters.clear(); characters.clear();
linux.setBeep (200, 100); linux.setBeep (200, 100);
CPPUNIT_ASSERT ( fsystest->characters == CSI "10;200]" CSI "11;100]" ); CPPUNIT_ASSERT ( characters == CSI "10;200]" CSI "11;100]" );
fsystest->characters.clear(); characters.clear();
linux.resetBeep(); linux.resetBeep();
CPPUNIT_ASSERT ( fsystest->characters == CSI "10;750]" CSI "11;125]" ); CPPUNIT_ASSERT ( characters == CSI "10;750]" CSI "11;125]" );
fsystest->characters.clear(); characters.clear();
linux.initCharMap (finalcut::fc::character); linux.initCharMap (finalcut::fc::character);
auto& character_map = data->getCharSubstitutionMap(); auto& character_map = data->getCharSubstitutionMap();
@ -1579,10 +1599,6 @@ void FTermLinuxTest::linuxConsoleTest()
CPPUNIT_ASSERT ( character_map[finalcut::fc::Times] == L'x' ); CPPUNIT_ASSERT ( character_map[finalcut::fc::Times] == L'x' );
CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'' ); CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'' );
// linux.loadVGAFont()
// linux.loadNewFont()
// linux.loadOldFont(finalcut::fc::character);
closeConEmuStdStreams(); closeConEmuStdStreams();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -2075,23 +2091,28 @@ void FTermLinuxTest::linuxFontTest()
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys);
console_font_op& font = fsystest->getConsoleFont(); console_font_op& font = fsystest->getConsoleFont();
CPPUNIT_ASSERT ( font.op == KD_FONT_OP_GET ); CPPUNIT_ASSERT ( font.op == KD_FONT_OP_GET );
CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() );
CPPUNIT_ASSERT ( ! linux.isNewFontUsed() );
linux.loadVGAFont(); linux.loadVGAFont();
CPPUNIT_ASSERT ( data->hasShadowCharacter() ); CPPUNIT_ASSERT ( data->hasShadowCharacter() );
CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() );
CPPUNIT_ASSERT ( font.op == KD_FONT_OP_SET ); CPPUNIT_ASSERT ( font.op == KD_FONT_OP_SET );
CPPUNIT_ASSERT ( linux.isVGAFontUsed() );
CPPUNIT_ASSERT ( ! linux.isNewFontUsed() );
// Full block character test // Full block character test
for (std::size_t i = 0; i < 16 ; i++) for (std::size_t i = 0; i < 16 ; i++)
CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff ); CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff );
linux.loadNewFont(); linux.loadNewFont();
CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() );
CPPUNIT_ASSERT ( linux.isNewFontUsed() );
// Full block character test // Full block character test
for (std::size_t i = 0; i < 16 ; i++) for (std::size_t i = 0; i < 16 ; i++)
CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff ); CPPUNIT_ASSERT ( font.data[219 * 32 + i] == 0xff );
// New font bullet // New font bullet
CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 );
CPPUNIT_ASSERT ( font.data[249 * 32 + 1] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 1] == 0x00 );
@ -2111,6 +2132,8 @@ void FTermLinuxTest::linuxFontTest()
CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 );
linux.loadOldFont(finalcut::fc::character); linux.loadOldFont(finalcut::fc::character);
CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() );
CPPUNIT_ASSERT ( ! linux.isNewFontUsed() );
// cp437 bullet operator // cp437 bullet operator
CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 0] == 0x00 );
@ -2145,6 +2168,435 @@ void FTermLinuxTest::linuxFontTest()
linux.finish(); linux.finish();
} }
//----------------------------------------------------------------------
void FTermLinuxTest::modifierKeyTest()
{
FKey keycode;
FKey mod_keycode;
const finalcut::FTermLinux linux;
finalcut::FSystem* fsys;
fsys = new test::FSystemTest();
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys);
test::FSystemTest::shiftstate& mod_key = fsystest->getShiftState();
// Up key
keycode = finalcut::fc::Fkey_up;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_up );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sr );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_up );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_up );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sup );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sup );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_up );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sup );
// Down key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_down;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_down );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sf );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_down );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_down );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sdown );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sdown );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_down );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sdown );
// Left key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_left;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_left );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sleft );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_left );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_left );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sleft );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sleft );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_left );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sleft );
// Right key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_right;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_right );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sright );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_right );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_right );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sright );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sright );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_right );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sright );
// Insert key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_ic;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_ic );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sic );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_ic );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_ic );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sic );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sic );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_ic );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sic );
// Delete key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_dc;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_dc );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sdc );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_dc );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_dc );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sdc );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sdc );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_dc );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sdc );
// Home key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_home;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_home );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_shome );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_home );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_home );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_shome );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_shome );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_home );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_shome );
// End key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_end;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_end );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_send );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_end );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_end );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_send );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_send );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_end );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_send );
// Page Up key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_ppage;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_ppage );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_sprevious );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_ppage );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_ppage );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_sppage );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_sppage );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_ppage );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_sppage );
// Page Down key
mod_key.shift = 0;
mod_key.ctrl = 0;
mod_key.alt = 0;
keycode = finalcut::fc::Fkey_npage;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_npage );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_snext );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_npage );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_npage );
mod_key.shift = 1;
mod_key.ctrl = 1;
mod_key.alt = 0;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fckey_snpage );
mod_key.ctrl = 0;
mod_key.alt = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fmkey_snpage );
mod_key.shift = 0;
mod_key.ctrl = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_npage );
mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fcmkey_snpage );
}
// Put the test suite in the registry // Put the test suite in the registry
CPPUNIT_TEST_SUITE_REGISTRATION (FTermLinuxTest); CPPUNIT_TEST_SUITE_REGISTRATION (FTermLinuxTest);