finalcut/test/ftermdetection-test.cpp

1736 lines
58 KiB
C++
Raw Normal View History

/***********************************************************************
* ftermdetection-test.cpp - FTermDetection unit tests *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
2021-04-11 21:00:06 +02:00
* Copyright 2018-2021 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestFixture.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
2018-09-15 01:54:02 +02:00
#include <sys/wait.h>
#include <sys/mman.h>
#include <conemu.h>
2018-10-24 08:51:38 +02:00
#include <final/final.h>
//----------------------------------------------------------------------
// class FTermDetectionTest
//----------------------------------------------------------------------
class FTermDetectionTest : public CPPUNIT_NS::TestFixture, test::ConEmu
{
public:
FTermDetectionTest();
~FTermDetectionTest();
protected:
void classNameTest();
void ansiTest();
void xtermTest();
void rxvtTest();
void urxvtTest();
void kdeKonsoleTest();
void gnomeTerminalTest();
void newerVteTerminalTest();
2020-08-30 22:47:24 +02:00
void puttyTest();
void windowsTerminalTest();
void teraTermTest();
void cygwinTest();
void minttyTest();
void linuxTest();
void freebsdTest();
void netbsdTest();
void openbsdTest();
void sunTest();
void screenTest();
void tmuxTest();
2020-08-30 22:47:24 +02:00
void ktermTest();
void mltermTest();
2021-04-11 21:00:06 +02:00
void kittyTest();
void ttytypeTest();
private:
// Adds code needed to register the test suite
CPPUNIT_TEST_SUITE (FTermDetectionTest);
// Add a methods to the test suite
CPPUNIT_TEST (classNameTest);
CPPUNIT_TEST (ansiTest);
CPPUNIT_TEST (xtermTest);
CPPUNIT_TEST (rxvtTest);
CPPUNIT_TEST (urxvtTest);
CPPUNIT_TEST (kdeKonsoleTest);
CPPUNIT_TEST (gnomeTerminalTest);
CPPUNIT_TEST (newerVteTerminalTest);
2020-08-30 22:47:24 +02:00
CPPUNIT_TEST (puttyTest);
CPPUNIT_TEST (windowsTerminalTest);
CPPUNIT_TEST (teraTermTest);
CPPUNIT_TEST (cygwinTest);
CPPUNIT_TEST (minttyTest);
CPPUNIT_TEST (linuxTest);
CPPUNIT_TEST (freebsdTest);
CPPUNIT_TEST (netbsdTest);
CPPUNIT_TEST (openbsdTest);
CPPUNIT_TEST (sunTest);
CPPUNIT_TEST (screenTest);
CPPUNIT_TEST (tmuxTest);
2020-08-30 22:47:24 +02:00
CPPUNIT_TEST (ktermTest);
CPPUNIT_TEST (mltermTest);
2021-04-11 21:00:06 +02:00
CPPUNIT_TEST (kittyTest);
CPPUNIT_TEST (ttytypeTest);
// End of test suite definition
CPPUNIT_TEST_SUITE_END();
};
//----------------------------------------------------------------------
FTermDetectionTest::FTermDetectionTest()
{ }
//----------------------------------------------------------------------
FTermDetectionTest::~FTermDetectionTest()
{ }
//----------------------------------------------------------------------
void FTermDetectionTest::classNameTest()
{
finalcut::FTermDetection d;
2019-10-05 23:20:07 +02:00
const finalcut::FString& classname = d.getClassName();
CPPUNIT_ASSERT ( classname == "FTermDetection" );
}
//----------------------------------------------------------------------
void FTermDetectionTest::ansiTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
setenv ("TERM", "ansi", 1);
2020-04-25 02:32:33 +02:00
data.setTermType("ansi");
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "ansi", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( ! detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT ( detect.getTermType() == "ansi" );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setAnsiTerminal(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::ansi);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::xtermTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("xterm");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm", 1);
setenv ("XTERM_VERSION", "XTerm(312)", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::xterm);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::rxvtTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("rxvt-cygwin-native");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "rxvt-cygwin-native", 1);
setenv ("COLORTERM", "rxvt-xpm", 1);
2018-09-18 06:04:27 +02:00
setenv ("COLORFGBG", "default;default", 1);
unsetenv("TERMCAP");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT ( detect.getTermType() == "rxvt-16color" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::rxvt);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::urxvtTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("rxvt-unicode-256color");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "rxvt-unicode-256color", 1);
setenv ("COLORTERM", "rxvt-xpm", 1);
2018-09-18 06:04:27 +02:00
setenv ("COLORFGBG", "default;default;0", 1);
unsetenv("TERMCAP");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::urxvt);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
2020-08-30 22:47:24 +02:00
void FTermDetectionTest::kdeKonsoleTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-08-30 22:47:24 +02:00
data.setTermType("xterm-256color");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
2020-08-30 22:47:24 +02:00
setenv ("TERM", "xterm-256color", 1);
setenv ("COLORTERM", "truecolor", 1);
setenv ("KONSOLE_DBUS_SERVICE", "DCOPRef(konsole-11768,konsole)", 1);
setenv ("KONSOLE_DCOP", ":1.77", 1);
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("TERMCAP");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::kde_konsole);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
2020-08-30 22:47:24 +02:00
void FTermDetectionTest::gnomeTerminalTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("xterm-256color");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
setenv ("COLORTERM", "truecolor", 1);
2020-08-30 22:47:24 +02:00
setenv ("VTE_VERSION", "5202", 1);
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("TERMCAP");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
2020-08-30 22:47:24 +02:00
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( detect.isGnomeTerminal() );
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::gnome_terminal);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
2020-08-30 22:47:24 +02:00
void FTermDetectionTest::newerVteTerminalTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("xterm-256color");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
setenv ("COLORTERM", "truecolor", 1);
2020-08-30 22:47:24 +02:00
setenv ("VTE_VERSION", "5300", 1);
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("TERMCAP");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::newer_vte_terminal);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
2020-08-30 22:47:24 +02:00
void FTermDetectionTest::puttyTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-08-30 22:47:24 +02:00
data.setTermType("xterm");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
2020-08-30 22:47:24 +02:00
setenv ("TERM", "xterm", 1);
unsetenv("TERMCAP");
2020-08-30 22:47:24 +02:00
unsetenv("COLORTERM");
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
CPPUNIT_ASSERT ( detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
2020-08-30 22:47:24 +02:00
enableConEmuDebug(true);
printConEmuDebug();
closeConEmuStdStreams();
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::putty);
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
2020-08-30 22:47:24 +02:00
void FTermDetectionTest::windowsTerminalTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-08-30 22:47:24 +02:00
data.setTermType("xterm");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
2020-08-30 22:47:24 +02:00
setenv ("TERM", "xterm-256color", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
2020-08-30 22:47:24 +02:00
setenv ("WT_PROFILE_ID", "{61c54cbd-c2a6-5271-96e7-009a87ff44bf}", 1);
setenv ("WT_SESSION", "4dc413a1-5ed9-46d4-b4e0-5a2fec7acb44", 1);
detect.detect();
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::win_terminal);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::teraTermTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("xterm");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::tera_term);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::cygwinTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("cygwin");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "cygwin", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::cygwin);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::minttyTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("xterm-256color");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm-256color", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( detect.hasSetCursorStyleSupport() );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::mintty);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::linuxTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("linux");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "linux", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setLinuxTerm(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::linux_con);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::freebsdTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("xterm");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "xterm", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
detect.setFreeBSDTerm (true); // Fake FreeBSD Console detection
CPPUNIT_ASSERT ( detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setXTerminal (false);
detect.setFreeBSDTerm(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::freebsd_con);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::netbsdTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("wsvt25");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "wsvt25", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
detect.setNetBSDTerm (true); // Fake NetBSD Console detection
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setNetBSDTerm(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::netbsd_con);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::openbsdTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("vt220");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "vt220", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
detect.setOpenBSDTerm (true); // Fake OpenBSD Console detection
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setOpenBSDTerm(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::openbsd_con);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::sunTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("sun-color");
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "sun-color", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( ! detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setSunTerminal(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::sun_con);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::screenTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("screen");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "screen", 1);
setenv ("TERMCAP", "SC|screen|VT 100/ANSI X3.64 virtual terminal:...", 1);
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT ( detect.getTermType() == "screen" );
2018-09-18 06:04:27 +02:00
setenv ("XTERM_VERSION", "XTerm(312)", 1);
detect.detect();
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.getTermType() == "screen-256color" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::screen);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::tmuxTest()
{
auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect;
2020-04-25 02:32:33 +02:00
data.setTermType("screen");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
setenv ("TERM", "screen", 1);
setenv ("TMUX", "/tmp/tmux-1000/default,7844,0", 1);
setenv ("TMUX_PANE", "%0", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( detect.isScreenTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( detect.isTmuxTerm() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT ( detect.getTermType() == "screen" );
2018-09-18 06:04:27 +02:00
setenv ("VTE_VERSION", "3801", 1);
detect.detect();
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.getTermType() == "screen-256color" );
printConEmuDebug();
closeConEmuStdStreams();
2018-09-15 01:54:02 +02:00
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal simulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::tmux);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
2020-08-30 22:47:24 +02:00
//----------------------------------------------------------------------
void FTermDetectionTest::ktermTest()
{
auto& data = finalcut::FTermData::getInstance();
2020-08-30 22:47:24 +02:00
finalcut::FTermDetection detect;
data.setTermType("kterm");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
2020-08-30 22:47:24 +02:00
setenv ("TERM", "kterm", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
2020-08-30 22:47:24 +02:00
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
CPPUNIT_ASSERT ( detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( ! detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( ! detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
// Test fallback to vt100 without TERM environment variable
unsetenv("TERM");
detect.setKtermTerminal(false);
detect.detect();
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
2020-08-30 22:47:24 +02:00
printConEmuDebug();
closeConEmuStdStreams();
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::kterm);
2020-08-30 22:47:24 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::mltermTest()
{
auto& data = finalcut::FTermData::getInstance();
2020-08-30 22:47:24 +02:00
finalcut::FTermDetection detect;
data.setTermType("mlterm");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
2020-08-30 22:47:24 +02:00
setenv ("TERM", "mlterm", 1);
setenv ("MLTERM", "3.8.4", 1);
setenv ("COLORFGBG", "default;default", 1);
unsetenv("TERMCAP");
unsetenv("COLORTERM");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
2020-08-30 22:47:24 +02:00
detect.detect();
CPPUNIT_ASSERT ( ! detect.isXTerminal() );
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( detect.isMltermTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isKittyTerminal() );
2020-08-30 22:47:24 +02:00
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT ( detect.getTermType() == "mlterm-256color" );
2020-08-30 22:47:24 +02:00
setenv ("TERM", "mlterm", 1);
unsetenv("COLORFGBG");
detect.detect();
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.getTermType() == "xterm-256color" );
2020-08-30 22:47:24 +02:00
printConEmuDebug();
closeConEmuStdStreams();
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::mlterm);
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::kittyTest()
{
auto& data = finalcut::FTermData::getInstance();
2021-04-11 21:00:06 +02:00
finalcut::FTermDetection detect;
data.setTermType("xterm-kitty");
detect.setTerminalDetection(true);
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
2021-04-11 21:00:06 +02:00
setenv ("TERM", "xterm-kitty", 1);
setenv ("KITTY_WINDOW_ID", "1", 1);
setenv ("COLORTERM", "truecolor", 1);
unsetenv("TERMCAP");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
detect.detect();
CPPUNIT_ASSERT ( detect.isXTerminal() );
2021-04-11 21:00:06 +02:00
CPPUNIT_ASSERT ( ! detect.isAnsiTerminal() );
CPPUNIT_ASSERT ( ! detect.isRxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isUrxvtTerminal() );
CPPUNIT_ASSERT ( ! detect.isKdeTerminal() );
CPPUNIT_ASSERT ( ! detect.isGnomeTerminal() );
CPPUNIT_ASSERT ( ! detect.isPuttyTerminal() );
CPPUNIT_ASSERT ( ! detect.isWindowsTerminal() );
CPPUNIT_ASSERT ( ! detect.isTeraTerm() );
CPPUNIT_ASSERT ( ! detect.isCygwinTerminal() );
CPPUNIT_ASSERT ( ! detect.isMinttyTerm() );
CPPUNIT_ASSERT ( ! detect.isLinuxTerm() );
CPPUNIT_ASSERT ( ! detect.isFreeBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isNetBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isOpenBSDTerm() );
CPPUNIT_ASSERT ( ! detect.isSunTerminal() );
CPPUNIT_ASSERT ( ! detect.isScreenTerm() );
CPPUNIT_ASSERT ( ! detect.isTmuxTerm() );
CPPUNIT_ASSERT ( ! detect.isKtermTerminal() );
CPPUNIT_ASSERT ( ! detect.isMltermTerminal() );
CPPUNIT_ASSERT ( detect.isKittyTerminal() );
CPPUNIT_ASSERT ( detect.canDisplay256Colors() );
CPPUNIT_ASSERT ( detect.hasTerminalDetection() );
CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() );
CPPUNIT_ASSERT ( detect.getTermType() == "xterm-kitty" );
2021-04-11 21:00:06 +02:00
auto kitty_version = detect.getKittyVersion();
CPPUNIT_ASSERT ( kitty_version.primary == 0 );
CPPUNIT_ASSERT ( kitty_version.secondary == 13 );
printConEmuDebug();
closeConEmuStdStreams();
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
startConEmuTerminal (ConEmu::console::kitty);
2020-08-30 22:47:24 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
}
//----------------------------------------------------------------------
void FTermDetectionTest::ttytypeTest()
{
2018-09-18 06:04:27 +02:00
// Test without TERM environment variable
if ( mkdir("new-root-dir", 0755) == -1 )
if ( errno != EEXIST )
return;
if ( mkdir("new-root-dir/etc", 0755) == -1 )
if ( errno != EEXIST )
return;
// Write a own /etc/ttytype file
std::ofstream ttytype ("new-root-dir/etc/ttytype");
if ( ! ttytype.is_open() )
{
rmdir("new-root-dir/etc");
rmdir("new-root-dir");
return;
}
ttytype << "linux" << "\t" << "tty1" << std::endl;
ttytype << "linux" << "\t" << "tty2" << std::endl;
ttytype << "linux" << "\t" << "tty3" << std::endl;
ttytype << "linux" << "\t" << "tty4" << std::endl;
ttytype << "linux" << "\t" << "tty5" << std::endl;
ttytype << "linux" << "\t" << "tty6" << std::endl;
ttytype << "vt100" << "\t" << "ttyp0" << std::endl;
ttytype << "vt100" << "\t" << "ttyp1" << std::endl;
ttytype << "vt100" << "\t" << "ttyp2" << std::endl;
ttytype << "vt100" << "\t" << "ttyp3" << std::endl;
ttytype << "vt100" << "\t" << "ttyp4" << std::endl;
ttytype << "vt100" << "\t" << "ttyp5" << std::endl;
ttytype << "vt100" << "\t" << "ttyp6" << std::endl;
ttytype.close();
finalcut::FTermDetection detect;
detect.setTerminalDetection(true);
2020-04-25 02:32:33 +02:00
detect.setTtyTypeFileName("new-root-dir/etc/ttytype");
pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) )
{
// (gdb) set follow-fork-mode child
unsetenv("TERM");
unsetenv("TERMCAP");
unsetenv("COLORTERM");
2018-09-18 06:04:27 +02:00
unsetenv("COLORFGBG");
unsetenv("VTE_VERSION");
unsetenv("XTERM_VERSION");
unsetenv("ROXTERM_ID");
unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP");
unsetenv("TMUX");
2021-04-11 21:00:06 +02:00
unsetenv("KITTY_WINDOW_ID");
auto& data = finalcut::FTermData::getInstance();
// Test /dev/tty3 with linux
2020-04-25 02:32:33 +02:00
data.setTermFileName("/dev/tty3");
detect.detect();
CPPUNIT_ASSERT ( detect.getTermType() == "linux" );
// Test /dev/ttyp0 with vt100
2020-04-25 02:32:33 +02:00
data.setTermFileName("/dev/ttyp0");
detect.detect();
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
// Test non-existent /dev/tty8 with fallback to vt100
2020-04-25 02:32:33 +02:00
data.setTermFileName("/dev/tty8");
detect.detect();
CPPUNIT_ASSERT ( detect.getTermType() == "vt100" );
printConEmuDebug();
closeConEmuStdStreams();
exit(EXIT_SUCCESS);
}
else // Parent
{
// Start the terminal emulation
2021-04-11 21:00:06 +02:00
startConEmuTerminal (ConEmu::console::ansi);
2018-09-18 03:37:44 +02:00
if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl;
}
unlink("new-root-dir/etc/ttytype");
rmdir("new-root-dir/etc");
rmdir("new-root-dir");
}
// Put the test suite in the registry
CPPUNIT_TEST_SUITE_REGISTRATION (FTermDetectionTest);
// The general unit test main part
#include <main-test.inc>