static void createRccBinaryData(const QString &baseDir, const QString &qrcFileName, const QString &rccFileName)
{
    QString currentDir = QDir::currentPath();
    QDir::setCurrent(baseDir);

    QProcess rccProcess;
    rccProcess.start("rcc", QStringList() << "-binary" << "-o" << rccFileName << qrcFileName);
    bool ok = rccProcess.waitForFinished();
    if (!ok) {
        QString errorString = QString::fromLatin1("Could not start rcc (is it in PATH?): %1").arg(rccProcess.errorString());
        QFAIL(qPrintable(errorString));
    }

    QByteArray output = rccProcess.readAllStandardOutput();
    if (!output.isEmpty()) {
        QString errorMessage = QString::fromLatin1("rcc stdout: %1").arg(QString::fromLocal8Bit(output));
        QWARN(qPrintable(errorMessage));
    }

    output = rccProcess.readAllStandardError();
    if (!output.isEmpty()) {
        QString errorMessage = QString::fromLatin1("rcc stderr: %1").arg(QString::fromLocal8Bit(output));
        QWARN(qPrintable(errorMessage));
    }

    QDir::setCurrent(currentDir);
}
예제 #2
0
void TestTask::testStart() {
	QCOMPARE(m_task->isStarted(), false);
	QVERIFY(m_task->totalElapsed() == 0);
	QVERIFY(m_task->sessionElapsed() == 0);

	m_task->start();

	QCOMPARE(m_task->isStarted(), true);
	QWARN("Waiting 3 seconds");
	QTest::qSleep(3000);
	m_task->stop();

	QCOMPARE(m_task->isStarted(), false);
	QVERIFY(m_task->totalElapsed() == 3);
	QVERIFY(m_task->sessionElapsed() == 3);

	m_task->newSession();

	m_task->start();
	QWARN("Waiting another 3 seconds");
	QTest::qSleep(3000);
	m_task->stop();
	QVERIFY(m_task->totalElapsed() == 6);
	QVERIFY(m_task->sessionElapsed() == 3);

	QVERIFY(m_task->calculateTime(QDateTime(), QDateTime()) == 6);
}
예제 #3
0
void TestWpaSup::initTestCase()
{
    qDebug() << "netctlgui library tests";
    qDebug() << "WpaSup class tests";
    qDebug() << "TODO: unfortunately, some functions which is required to work";
    qDebug() << "with the working profile isn't tested here (including netctl-auto)";
    QWARN("Some functions requires root privileges");
    if (sendDBusRequest(QString("/ctrl"), QString("Active")).isEmpty()) {
        helper = false;
        QWARN("Helper isn't active. DBus tests will be ignored");
    } else
        helper = true;
}
예제 #4
0
void tst_QPluginLoader::checkingStubsFromDifferentDrives()
{
#if defined(Q_OS_SYMBIAN)

    // This test needs C-drive + some additional drive (driveForStubs)

    const QString driveForStubs("E:/");// != "C:/"
    const QString stubDir("system/temp/stubtest/");
    const QString stubName("dummyStub.qtplugin");
    const QString fullStubFileName(stubDir + stubName);
    QDir dir(driveForStubs);
    bool test1(false); bool test2(false);

    // initial clean up
    QFile::remove(driveForStubs + fullStubFileName);
    dir.rmdir(driveForStubs + stubDir);

    // create a stub dir and do stub drive check
    if (!dir.mkpath(stubDir))
        QSKIP("Required drive not available for this test", SkipSingle);

    {// test without stub, should not be found
    QPluginLoader loader("C:/" + fullStubFileName);
    test1 = !loader.fileName().length();
    }

    // create a stub to defined drive
    QFile tempFile(driveForStubs + fullStubFileName);
    tempFile.open(QIODevice::ReadWrite);
    QFileInfo fileInfo(tempFile);

    {// now should be found even tried to find from C:
    QPluginLoader loader("C:/" + fullStubFileName);
    test2 = (loader.fileName() == fileInfo.absoluteFilePath());
    }

    // clean up
    tempFile.close();
    if (!QFile::remove(driveForStubs + fullStubFileName))
        QWARN("Could not remove stub file");
    if (!dir.rmdir(driveForStubs + stubDir))
        QWARN("Could not remove stub directory");

    // test after cleanup
    QVERIFY(test1);
    QVERIFY(test2);

#endif//Q_OS_SYMBIAN
}
예제 #5
0
void tst_QNumeric::qNan()
{
    double nan = qQNaN();
#if defined( __INTEL_COMPILER)
    QCOMPARE((0 > nan), false);
    QCOMPARE((0 < nan), false);
    QSKIP("This fails due to a bug in the Intel Compiler", SkipAll);
#else
    if (0 > nan)
        QFAIL("compiler thinks 0 > nan");

#  if defined(Q_CC_DIAB)
    QWARN("!(0 < nan) would fail due to a bug in dcc");
#  else
    if (0 < nan)
        QFAIL("compiler thinks 0 < nan");
#  endif
#endif
    QVERIFY(qIsNaN(nan));
    QVERIFY(qIsNaN(nan + 1));
    QVERIFY(qIsNaN(-nan));
    double inf = qInf();
    QVERIFY(inf > 0);
    QVERIFY(-inf < 0);
    QVERIFY(qIsInf(inf));
    QVERIFY(qIsInf(-inf));
    QVERIFY(qIsInf(2*inf));
    QCOMPARE(1/inf, 0.0);
    QVERIFY(qIsNaN(0*nan));
    QVERIFY(qIsNaN(0*inf));
    QVERIFY(qFuzzyCompare(1/inf, 0.0));
}
예제 #6
0
파일: apptests.cpp 프로젝트: afk11/bitcoin
//! Entry point for BitcoinApplication tests.
void AppTests::appTests()
{
#ifdef Q_OS_MAC
    if (QApplication::platformName() == "minimal") {
        // Disable for mac on "minimal" platform to avoid crashes inside the Qt
        // framework when it tries to look up unimplemented cocoa functions,
        // and fails to handle returned nulls
        // (https://bugreports.qt.io/browse/QTBUG-49686).
        QWARN("Skipping AppTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke "
              "with 'test_bitcoin-qt -platform cocoa' on mac, or else use a linux or windows build.");
        return;
    }
#endif

    m_app.parameterSetup();
    m_app.createOptionsModel(true /* reset settings */);
    QScopedPointer<const NetworkStyle> style(
        NetworkStyle::instantiate(QString::fromStdString(Params().NetworkIDString())));
    m_app.setupPlatformStyle();
    m_app.createWindow(style.data());
    connect(&m_app, &BitcoinApplication::windowShown, this, &AppTests::guiTests);
    expectCallback("guiTests");
    m_app.baseInitialize();
    m_app.requestInitialize();
    m_app.exec();
    m_app.requestShutdown();
    m_app.exec();

    // Reset global state to avoid interfering with later tests.
    AbortShutdown();
    UnloadBlockIndex();
}
예제 #7
0
/* We compare the calculated runtimes against two values:
 * - Known runtime calculated by Subsurface previously (to detect if anything has changed)
 * - Benchmark runtime (we should be close, but not always exactly the same)
 */
bool compareDecoTime(int actualRunTimeSeconds, int benchmarkRunTimeSeconds, int knownSsrfRunTimeSeconds)
{
	bool result;

	// If the calculated run time equals the expected run time, do a simple comparison
	if (actualRunTimeSeconds == benchmarkRunTimeSeconds) {
		result = true;
	} else {
		/* We want the difference between the expected and calculated total run time to be not more than
		* 1% of total run time + 1 minute */
		int permilDifferenceAllowed = 1 * 10;
		int absoluteDifferenceAllowedSeconds = 60;
		int totalDifferenceAllowed = 0.001 * permilDifferenceAllowed * benchmarkRunTimeSeconds + absoluteDifferenceAllowedSeconds;
		int totalDifference = abs(actualRunTimeSeconds - benchmarkRunTimeSeconds);

		qDebug("Calculated run time = %d seconds", actualRunTimeSeconds);
		qDebug("Expected run time = %d seconds", benchmarkRunTimeSeconds);
		qDebug("Allowed time difference is %g percent plus %d seconds = %d seconds",
		       permilDifferenceAllowed * 0.1, absoluteDifferenceAllowedSeconds, totalDifferenceAllowed);
		qDebug("total difference = %d seconds", totalDifference);

		result = (totalDifference <= totalDifferenceAllowed);
	}
	if ((knownSsrfRunTimeSeconds > 0) && (actualRunTimeSeconds != knownSsrfRunTimeSeconds)) {
		QWARN("Calculated run time does not match known Subsurface runtime");
		qWarning("Calculated runtime: %d", actualRunTimeSeconds);
		qWarning("Known Subsurface runtime: %d", knownSsrfRunTimeSeconds);
	}
	return result;
}
예제 #8
0
void ECMAscriptTest::initTestCase()
{
    basedir = QString::fromUtf8( qgetenv( "ECMATEST_BASEDIR" ) );

    if ( basedir.isEmpty() )
        qFatal( "ECMATEST_BASEDIR not set" );

    if ( !basedir.endsWith( QLatin1Char( '/' ) ) )
        basedir += QLatin1Char( '/' );

    QVERIFY( loadInclude( "sta.js" ) );
    QVERIFY( loadInclude( "ed.js" ) );

    testrunner = includes[ "sta.js" ] + includes[ "ed.js" ] + '\n';

    const QString brokenFn = QString::fromAscii( qgetenv( "ECMATEST_BROKEN" ) );
    if ( !brokenFn.isEmpty() ) {
        QFile brokenF( brokenFn );
        if ( !brokenF.open( QIODevice::ReadOnly ) ) {
            const QString errmsg = QString::fromAscii( "cannot open " ) + brokenFn;
            QWARN( errmsg.toAscii() );
        } else {
            expectedBroken = QString::fromAscii( brokenF.readAll() ).split( QLatin1Char( '\n' ) )
                                               .filter( QRegExp( "^[^#].*" ) );
        }
    }

    m_passed = 0;
}
예제 #9
0
void tst_ICheck::doTests()
{
    QString msg;
    QString xmltestfile = getTestFileFolder();
    xmltestfile += "/Test.xml";
    QFile xmlfile(xmltestfile);
    bool failed = false;
    if (xmlfile.exists()){
        QDomDocument document;
        if (document.setContent(&xmlfile)) {
            QDomElement rootnd = document.documentElement();
            if(rootnd.isElement()){
                QDomNodeList nodeList = rootnd.childNodes();
                for(int i = 0; i < nodeList.count(); i++){
                    QDomNode nd = nodeList.at(i);
                    TestCase test(nd);
                    if(!test.run()){
                        QWARN(test.getErrorMsg().toLatin1());
                        failed = true;
                    }
                }
            }
        }
    }
    else {
        QFAIL ( QString(xmltestfile + " file not found").toLatin1() );
    }
    if(failed)
        QFAIL ( "Test failed, please read warnings!" );
}
예제 #10
0
void TestLogData::randomPageReadExpanded()
{
    LogData logData;

    // Register for notification file is loaded
    connect( &logData, SIGNAL( loadingFinished( bool ) ),
             this, SLOT( loadingFinished() ) );

    logData.attachFile( TMPDIR "/verybiglog.txt" );
    // Wait for the loading to be done
    {
        QApplication::exec();
    }

    QWARN("Starting random page read test (expanded lines)");

    // Read page by page from the beginning and the end, using the QStringList
    // function
    QStringList list;
    QBENCHMARK {
        for (int page = 0; page < (VBL_NB_LINES/VBL_LINE_PER_PAGE)-1; page++)
        {
            list = logData.getExpandedLines( page*VBL_LINE_PER_PAGE, VBL_LINE_PER_PAGE );
            QCOMPARE(list.count(), VBL_LINE_PER_PAGE);
            int page_from_end = (VBL_NB_LINES/VBL_LINE_PER_PAGE) - page - 1;
            list = logData.getExpandedLines( page_from_end*VBL_LINE_PER_PAGE, VBL_LINE_PER_PAGE );
            QCOMPARE(list.count(), VBL_LINE_PER_PAGE);
        }
    }
}
예제 #11
0
void TestCsvParser::testMalformed()
{
    parser->setTextQualifier(':');
    QTextStream out(file.data());
    out << "A,B,C\n:BM::,1,:2:";
    QEXPECT_FAIL("", "Bad format", Continue);
    QVERIFY(parser->parse(file.data()));
    t = parser->getCsvTable();
    QWARN(parser->getStatus().toLatin1());
}
예제 #12
0
void FileWatchUnitTest::filewatchTest()
{
    QWARN("Unittest will take about 1 minute. Please wait.");

    QCA::FileWatch watcher;
    QCOMPARE( watcher.fileName(), QString() );

    QSignalSpy spy( &watcher, SIGNAL(changed()) );
    QVERIFY( spy.isValid() );
    QCOMPARE( spy.count(), 0 );

    QTemporaryFile *tempFile = new QTemporaryFile;

    tempFile->open();

    watcher.setFileName( tempFile->fileName() );
    QCOMPARE( watcher.fileName(), tempFile->fileName() );
    QTest::qWait(7000);
    QCOMPARE( spy.count(), 0 );
    tempFile->close();
    QTest::qWait(7000);
    QCOMPARE( spy.count(), 0 );

    tempFile->open();
    tempFile->write("foo");
    tempFile->flush();
    QTest::qWait(7000);
    QCOMPARE( spy.count(), 1 );

    tempFile->close();
    QTest::qWait(7000);

    QCOMPARE( spy.count(), 1 );

    tempFile->open();
    tempFile->write("foo");
    tempFile->flush();
    QTest::qWait(7000);
    QCOMPARE( spy.count(), 2 );

    tempFile->write("bar");
    tempFile->flush();
    QTest::qWait(7000);
    QCOMPARE( spy.count(), 3 );

    tempFile->close();
    QTest::qWait(7000);

    QCOMPARE( spy.count(), 3 );

    delete tempFile;
    QTest::qWait(7000);
    QCOMPARE( spy.count(), 4 );
    
}
static QStringList readLinesFromFile(const QString &fileName)
{
    QFile file(fileName);

    bool ok = file.open(QIODevice::ReadOnly | QIODevice::Text);
    if (!ok)
        QWARN(qPrintable(QString::fromLatin1("Could not open testdata file %1: %2").arg(fileName, file.errorString())));

    QStringList lines = QString::fromUtf8(file.readAll()).split(QLatin1Char('\n'), QString::SkipEmptyParts);
    return lines;
}
예제 #14
0
QCheckBox * GraphicalBoolTest::findCheckBox(const GraphicalBool* value)
{
  // /!\ WARNING /!\
  // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
  // OF THE GRAPHICAL LOOK OF GraphicalBool

  QHBoxLayout * layout = dynamic_cast<QHBoxLayout*>(value->layout());
  QCheckBox * checkBox = nullptr;

  if( is_not_null(layout) )
  {
    checkBox = dynamic_cast<QCheckBox*>(layout->itemAt(0)->widget());

    if( is_null(checkBox) )
      QWARN("Failed to find the check box.");
  }
  else
    QWARN("Failed to find the layout or cast it to QHBoxLayout.");

  return checkBox;
}
예제 #15
0
void AbstractTestSuite::createExpectFailConfigFile()
{
    QFile file(expectFailConfigPath);
    if (!file.open(QFile::WriteOnly))
        return;
    QWARN(qPrintable(QString::fromLatin1("creating %0").arg(expectFailConfigPath)));
    QTextStream stream(&file);

    writeExpectFailConfigFile(stream);

    file.close();
}
예제 #16
0
QLineEdit * GraphicalDoubleTest::findLineEdit(const GraphicalDouble* value)
{
  // /!\ WARNING /!\
  // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
  // OF THE GRAPHICAL LOOK OF GraphicalDouble

  QHBoxLayout * layout = dynamic_cast<QHBoxLayout*>(value->layout());
  QLineEdit * lineEdit = nullptr;

  if( is_not_null(layout) )
  {
    lineEdit = dynamic_cast<QLineEdit*>(layout->itemAt(0)->widget());

    if( is_null(lineEdit) )
      QWARN("Failed to find the line edit.");
  }
  else
    QWARN("Failed to find the layout or cast it to QHBoxLayout.");

  return lineEdit;
}
예제 #17
0
QDoubleSpinBox * GraphicalIntTest::findSpinBox(const GraphicalInt* value)
{
  // /!\ WARNING /!\
  // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
  // OF THE GRAPHICAL LOOK OF GraphicalInt

  QHBoxLayout * layout = dynamic_cast<QHBoxLayout*>(value->layout());
  QDoubleSpinBox * spinBox = nullptr;

  if( is_not_null(layout) )
  {
    spinBox = dynamic_cast<QDoubleSpinBox*>(layout->itemAt(0)->widget());

    if( is_null(spinBox) )
      QWARN("Failed to find the spin box.");
  }
  else
    QWARN("Failed to find the layout or cast it to QHBoxLayout.");

  return spinBox;
}
예제 #18
0
QPushButton * GraphicalArrayTest::findRemoveButton(const GraphicalArray* value)
{
  // /!\ WARNING /!\
  // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
  // OF THE GRAPHICAL LOOK OF GraphicalArray

  QPushButton * button = dynamic_cast<QPushButton*>(findWidget(value, 1, 1));

  if( is_null(button) )
    QWARN("Failed to find the remove button.");

  return button;
}
예제 #19
0
QListView * GraphicalArrayTest::findListView(const GraphicalArray* value)
{
  // /!\ WARNING /!\
  // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
  // OF THE GRAPHICAL LOOK OF GraphicalArray

  QListView * listView = dynamic_cast<QListView*>(findWidget(value, 1, 0));

  if( is_null(listView) )
    QWARN("Failed to find the list.");

  return listView;
}
예제 #20
0
void AddressBookTests::addressBookTests()
{
#ifdef Q_OS_MAC
    if (QApplication::platformName() == "minimal") {
        // Disable for mac on "minimal" platform to avoid crashes inside the Qt
        // framework when it tries to look up unimplemented cocoa functions,
        // and fails to handle returned nulls
        // (https://bugreports.qt.io/browse/QTBUG-49686).
        QWARN("Skipping AddressBookTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke "
              "with 'test_bitcoin-qt -platform cocoa' on mac, or else use a linux or windows build.");
        return;
    }
#endif
    TestAddAddressesToSendBook();
}
예제 #21
0
static void mouseEvent(MouseAction _action, QWindow* _window, QObject* _item, Qt::MouseButton _button, Qt::KeyboardModifiers _stateKey, QPointF _pos, int _delay = -1)
{
    if (_delay == -1 || _delay < 30)
        _delay = 30;
    if (_delay > 0)
        QTest::qWait(_delay);

    if (_action == MouseClick)
    {
        mouseEvent(MousePress, _window, _item, _button, _stateKey, _pos);
        mouseEvent(MouseRelease, _window, _item, _button, _stateKey, _pos);
        return;
    }

    QPoint pos = _pos.toPoint();
    QQuickItem* sgitem = qobject_cast<QQuickItem*>(_item);
    if (sgitem)
        pos = sgitem->mapToScene(_pos).toPoint();

    _stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);

    QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, _button, _stateKey);
    switch (_action)
    {
    case MousePress:
        me = QMouseEvent(QEvent::MouseButtonPress, pos, _window->mapToGlobal(pos), _button, _button, _stateKey);
        break;
    case MouseRelease:
        me = QMouseEvent(QEvent::MouseButtonRelease, pos, _window->mapToGlobal(pos), _button, 0, _stateKey);
        break;
    case MouseDoubleClick:
        me = QMouseEvent(QEvent::MouseButtonDblClick, pos, _window->mapToGlobal(pos), _button, _button, _stateKey);
        break;
    case MouseMove:
        // with move event the _button is NoButton, but 'buttons' holds the currently pressed buttons
        me = QMouseEvent(QEvent::MouseMove, pos, _window->mapToGlobal(pos), Qt::NoButton, _button, _stateKey);
        break;
    default:
        break;
    }
    QSpontaneKeyEvent::setSpontaneous(&me);
    if (!qApp->notify(_window, &me))
    {
        static const char* mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" };
        QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window");
        QWARN(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(_action)])).toLatin1().data());
    }
}
예제 #22
0
QWidget * GraphicalArrayTest::findWidget(const GraphicalArray* value, int row, int col)
{
  // /!\ WARNING /!\
  // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
  // OF THE GRAPHICAL LOOK OF GraphicalArray

  QGridLayout * layout = dynamic_cast<QGridLayout*>(value->layout()->itemAt(0)->widget()->layout());
  QWidget * widget = nullptr;

  if( is_not_null(layout) )
    widget = layout->itemAtPosition(row, col)->widget();
  else
    QWARN("Failed to find the layout or cast it to QGridLayout.");

  return widget;
}
예제 #23
0
MasterScore* MTest::readCreatedScore(const QString& name)
      {
      MasterScore* score = new MasterScore(mscore->baseStyle());
      QFileInfo fi(name);
      score->setName(fi.completeBaseName());
      QString csl  = fi.suffix().toLower();

      ScoreLoad sl;
      Score::FileError rv;
      if (csl == "cap") {
            rv = importCapella(score, name);
            score->setMetaTag("originalFormat", csl);
            }
      else if (csl == "capx") {
            rv = importCapXml(score, name);
            score->setMetaTag("originalFormat", csl);
            }
      else if (csl == "ove")
            rv = importOve(score, name);
      else if (csl == "sgu")
            rv = importBB(score, name);
      else if (csl == "mscz" || csl == "mscx")
            rv = score->loadMsc(name, false);
      else if (csl == "mxl")
            rv = importCompressedMusicXml(score, name);
#ifdef OMR
      else if (csl == "pdf")
            rv = importPdf(score, name);
#endif
      else if (csl == "xml" || csl == "musicxml")
            rv = importMusicXml(score, name);
      else if (csl == "gp3" || csl == "gp4" || csl == "gp5" || csl == "gpx")
            rv = importGTP(score, name);
      else
            rv = Score::FileError::FILE_UNKNOWN_TYPE;

      if (rv != Score::FileError::FILE_NO_ERROR) {
            QWARN(qPrintable(QString("readScore: cannot load <%1> type <%2>\n").arg(name).arg(csl)));
            delete score;
            score = 0;
            }
      else {
            for (Score* s : score->scoreList())
                  s->doLayout();
            }
      return score;
      }
예제 #24
0
void TestNetctl::test_getRecommendedConfiguration()
{
    QStringList original;
    original.append(QString("FORCE_SUDO==false"));
    original.append(QString("IFACE_DIR==/sys/class/net"));
    original.append(QString("NETCTLAUTO_PATH==/usr/bin/netctl-auto"));
    original.append(QString("NETCTLAUTO_SERVICE==netctl-auto"));
    original.append(QString("NETCTL_PATH==/usr/bin/netctl"));
    original.append(QString("PREFERED_IFACE==wifi0"));
    original.append(QString("PROFILE_DIR==/etc/netctl"));
    original.append(QString("SUDO_PATH==/usr/bin/sudo"));
    original.append(QString("SYSTEMCTL_PATH==/usr/bin/systemctl"));
    QMap<QString, QString> resultMap = Netctl::getRecommendedConfiguration();

    QWARN("This test may fail on other configuration");
    QCOMPARE(mapToList(resultMap), original);
}
void logFailure(const QString & reason, const KoColorSpace * srcCs, const KoColorSpace * dstCs)
{
    QString profile1("no profile");
    QString profile2("no profile");
    if (srcCs->profile())
        profile1 = srcCs->profile()->name();
    if (dstCs->profile())
        profile2 = dstCs->profile()->name();

    QWARN(QString("Failed %1 %2 -> %3 %4 %5")
          .arg(srcCs->name())
          .arg(profile1)
          .arg(dstCs->name())
          .arg(profile2)
          .arg(reason)
          .toLatin1());
}
예제 #26
0
void tst_QLogSystem::sysLoggerOutput()
{
    QString expected = "[Debug] Test: '12' 'string' '12.25'\n";

    SysLogger<LvlLogPrefix>* sysLogger = new SysLogger<LvlLogPrefix>("QMail logger test", LOG_PID, LOG_LOCAL7);
    sysLogger->setMinLogLvl(LlDbg);

    QString err_msg;
    QVERIFY2(sysLogger->isReady(err_msg), "File logger is not ready with local dir.");
    QVERIFY2(err_msg.isEmpty(), "File logger has obtained error message with local dir");

    LogSystem::getInstance().addLogger(sysLogger);
    LogSystem::getInstance().log(LlDbg, "Test: '%d' '%s' '%.2f'", 12,  "string", 12.25);
    LogSystem::getInstance().clear();

    QWARN (qPrintable(tr("Now You should see the string") + expected + tr("at syslog output LOG_LOCAL7, LOG_INFO")));
}
예제 #27
0
void TestWpaSup::test_getRecommendedConfiguration()
{
    QStringList original;
    original.append(QString("CTRL_DIR==/run/wpa_supplicant_netctl-gui"));
    original.append(QString("CTRL_GROUP==network"));
    original.append(QString("FORCE_SUDO==false"));
    original.append(QString("PID_FILE==/run/wpa_supplicant_netctl-gui.pid"));
    original.append(QString("SUDO_PATH==/usr/bin/sudo"));
    original.append(QString("WPACLI_PATH==/usr/bin/wpa_cli"));
    original.append(QString("WPASUP_PATH==/usr/bin/wpa_supplicant"));
    original.append(QString("WPA_DRIVERS==nl80211,wext"));
    QMap<QString, QString> resultMap = WpaSup::getRecommendedConfiguration();
    QStringList result;
    for (int i=0; i<resultMap.keys().count(); i++)
        result.append(resultMap.keys()[i] + QString("==") + resultMap[resultMap.keys()[i]]);

    QWARN("This test may fail on other configuration");
    QCOMPARE(result, original);
}
예제 #28
0
QStringListModel * GraphicalArrayTest::findModel(const GraphicalArray* value)
{
  // /!\ WARNING /!\
  // THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
  // OF THE GRAPHICAL LOOK OF GraphicalArray

  QListView * view = findListView(value);
  QStringListModel * model = nullptr;

  if( is_not_null(view) )
  {
    model = dynamic_cast<QStringListModel*>( view->model() );

    if( is_null(model) )
      QWARN("Failed to find the view model.");
  }

  return model;
}
예제 #29
0
void TestNetctl::test_getRecommendedConfiguration()
{
    QStringList original;
    original.append(QString("FORCE_SUDO==false"));
    original.append(QString("IFACE_DIR==/sys/class/net"));
    original.append(QString("NETCTLAUTO_PATH==/usr/bin/netctl-auto"));
    original.append(QString("NETCTLAUTO_SERVICE==netctl-auto"));
    original.append(QString("NETCTL_PATH==/usr/bin/netctl"));
    original.append(QString("PREFERED_IFACE==wifi0"));
    original.append(QString("PROFILE_DIR==/etc/netctl"));
    original.append(QString("SUDO_PATH==/usr/bin/sudo"));
    original.append(QString("SYSTEMCTL_PATH==/usr/bin/systemctl"));
    QMap<QString, QString> resultMap = Netctl::getRecommendedConfiguration();
    QStringList result;
    for (int i=0; i<resultMap.keys().count(); i++)
        result.append(resultMap.keys()[i] + QString("==") + resultMap[resultMap.keys()[i]]);

    QWARN("This test may fail on other configuration");
    QCOMPARE(result, original);
}
예제 #30
0
Score* MTest::readCreatedScore(const QString& name)
      {
      Score* score = new Score(mscore->baseStyle());
      QFileInfo fi(name);
      score->setName(fi.completeBaseName());
//      MScore::testMode = true;
      QString csl  = fi.suffix().toLower();

      Score::FileError rv;
      if (csl == "cap")
            rv = importCapella(score, name);
      else if (csl == "capx")
            rv = importCapXml(score, name);
      else if (csl == "ove")
            rv = importOve(score, name);
      else if (csl == "sgu")
            rv = importBB(score, name);
      else if (csl == "mscz" || csl == "mscx")
            rv = score->loadMsc(name, false);
      else if (csl == "mxl")
            rv = importCompressedMusicXml(score, name);
#ifdef OMR
      else if (csl == "pdf")
            rv = importPdf(score, name);
#endif
      else if (csl == "xml")
            rv = importMusicXml(score, name);
      else if (csl == "gp3" || csl == "gp4" || csl == "gp5" || csl == "gpx")
            rv = importGTP(score, name);
      else
            rv = Score::FileError::FILE_UNKNOWN_TYPE;


      if (rv != Score::FileError::FILE_NO_ERROR) {
            QWARN(qPrintable(QString("readScore: cannot load <%1> type <%2>\n").arg(name).arg(csl)));
            delete score;
            return 0;
            }
      return score;
      }