File indexing completed on 2024-04-28 05:50:35

0001 /*
0002     SPDX-FileCopyrightText: 2008 Robert Knight <robertknight@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 // Own
0008 #include "PtyTest.h"
0009 
0010 // Qt
0011 #include <QSize>
0012 #include <QStringList>
0013 
0014 // KDE
0015 #include <QTest>
0016 
0017 using namespace Konsole;
0018 
0019 void PtyTest::init()
0020 {
0021 }
0022 
0023 void PtyTest::cleanup()
0024 {
0025 }
0026 
0027 void PtyTest::testFlowControl()
0028 {
0029     Pty pty;
0030     const bool input = true;
0031     pty.setFlowControlEnabled(input);
0032     const bool output = pty.flowControlEnabled();
0033     QCOMPARE(output, input);
0034 }
0035 
0036 void PtyTest::testEraseChar()
0037 {
0038     Pty pty;
0039     const char input = 'x';
0040     pty.setEraseChar(input);
0041     const char output = pty.eraseChar();
0042     QCOMPARE(output, input);
0043 }
0044 
0045 void PtyTest::testUseUtmp()
0046 {
0047     Pty pty;
0048     const bool input = true;
0049     pty.setUseUtmp(input);
0050     const bool output = pty.isUseUtmp();
0051     QCOMPARE(output, input);
0052 }
0053 
0054 void PtyTest::testWindowSize()
0055 {
0056     // Maybe https://bugreports.qt.io/browse/QTBUG-82351 ???
0057     QSKIP("Skipping on CI suse_tumbelweed_qt64", SkipSingle);
0058     return;
0059 
0060     Pty pty;
0061     QSize input(80, 40);
0062     QSize pxInput(80 * 8, 40 * 16);
0063     pty.setWindowSize(input.width(), input.height(), pxInput.width(), pxInput.height());
0064     QSize output = pty.windowSize();
0065     QCOMPARE(output, input);
0066     QSize pxOutput = pty.pixelSize();
0067     QCOMPARE(pxOutput, pxInput);
0068 }
0069 
0070 void PtyTest::testRunProgram()
0071 {
0072     // Maybe https://bugreports.qt.io/browse/QTBUG-82351 ???
0073     QSKIP("Skipping on CI suse_tumbelweed_qt64", SkipSingle);
0074     return;
0075 
0076     Pty pty;
0077     QString program = QStringLiteral("sh");
0078     QStringList arguments;
0079     arguments << program;
0080     QStringList environments;
0081     const int result = pty.start(program, arguments, environments);
0082 
0083     QCOMPARE(result, 0);
0084     auto fpg = pty.foregroundProcessGroup();
0085     auto pid = pty.processId();
0086     // Try using variables in the QCOMPARE due to random failures on CI
0087     QCOMPARE(fpg, pid);
0088     pty.close();
0089 }
0090 
0091 QTEST_GUILESS_MAIN(PtyTest)
0092 
0093 #include "moc_PtyTest.cpp"