void tst_QUndoGroup::commandTextFormat() { QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); if (QProcess::execute(binDir + "/lrelease -version") != 0) QSKIP("lrelease is missing or broken"); QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/qundogroup.ts")); QTranslator translator; QVERIFY(translator.load("testdata/qundogroup.qm")); qApp->installTranslator(&translator); QUndoGroup group; QAction *undo_action = group.createUndoAction(0); QAction *redo_action = group.createRedoAction(0); QCOMPARE(undo_action->text(), QString("Undo-default-text")); QCOMPARE(redo_action->text(), QString("Redo-default-text")); QUndoStack stack(&group); stack.setActive(); QString str; stack.push(new AppendCommand(&str, "foo")); QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); QCOMPARE(redo_action->text(), QString("Redo-default-text")); stack.push(new InsertCommand(&str, 0, "bar")); stack.undo(); QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); QCOMPARE(redo_action->text(), QString("redo-prefix insert redo-suffix")); stack.undo(); QCOMPARE(undo_action->text(), QString("Undo-default-text")); QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix")); qApp->removeTranslator(&translator); }
void tst_QTextScriptEngine::thaiIsolatedSaraAm() { if (QFontDatabase().families(QFontDatabase::Any).contains("Waree")) { QString s; s.append(QChar(0x0e33)); QTextLayout layout(s, QFont("Waree")); layout.beginLayout(); layout.createLine(); layout.endLayout(); QTextEngine *e = layout.engine(); e->itemize(); e->shape(0); QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3)); unsigned short *logClusters = e->layoutData->logClustersPtr; QCOMPARE(logClusters[0], ushort(0)); } else QSKIP("Cannot find Waree.", SkipAll); }
void tst_QTabBar::sizeHints() { QTabBar tabBar; QSKIP("To be fixed on Mac (font size below not large enough) and Linux QWS (probably too large for the screen).", SkipSingle); tabBar.setFont(QFont("Arial", 10)); tabBar.addTab("tab 01"); tabBar.addTab("tab 02"); tabBar.addTab("tab 03"); tabBar.addTab("tab 04"); tabBar.addTab("tab 05"); tabBar.addTab("tab 06"); tabBar.addTab("This is tab7"); tabBar.addTab("This is tab8"); tabBar.addTab("This is tab9 with a very long title"); // No eliding and no scrolling -> tabbar becomes very wide tabBar.setUsesScrollButtons(false); tabBar.setElideMode(Qt::ElideNone); // qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); QVERIFY(tabBar.minimumSizeHint().width() > 700); QVERIFY(tabBar.sizeHint().width() > 700); // Scrolling enabled -> no reason to become very wide tabBar.setUsesScrollButtons(true); // qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); QVERIFY(tabBar.minimumSizeHint().width() < 200); QVERIFY(tabBar.sizeHint().width() > 700); // unchanged // Eliding enabled -> no reason to become very wide tabBar.setUsesScrollButtons(false); tabBar.setElideMode(Qt::ElideRight); // qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); QVERIFY(tabBar.minimumSizeHint().width() < 500); QVERIFY(tabBar.sizeHint().width() > 700); // unchanged tabBar.addTab("This is tab10 with a very long title"); QVERIFY(tabBar.minimumSizeHint().width() < 600); QVERIFY(tabBar.sizeHint().width() > 700); // unchanged }
void TestSymbianEngine::ctors() { QContactManager::Error error; QMap<QString, QString> params; // Ctor CntSymbianEngine *ce; ce = new CntSymbianEngine(params, &error); QVERIFY(ce != NULL); QVERIFY(error == QContactManager::NoError); if (error == QContactManager::NoError) { QVERIFY(ce->managerName() == CNT_SYMBIAN_MANAGER_NAME); QVERIFY(ce->m_contactFilter != 0); QVERIFY(ce->m_dataBase != 0); QVERIFY(ce->m_relationship != 0); QVERIFY(ce->m_transformContact != 0); } else { QSKIP("Error creating CntSymbianEngine in ctor", SkipSingle); } delete ce; }
void tst_QDirModel::hidden() { #ifndef Q_OS_UNIX QSKIP("Test not implemented on non-Unixes"); #else QDir current; current.mkdir(".qtest_hidden"); QDirModel model; QModelIndex index = model.index(QDir::currentPath() + "/.qtest_hidden"); //QVERIFY(!index.isValid()); // hidden items are not listed, but if you specify a valid path, it will give a valid index current.mkdir(".qtest_hidden/qtest_visible"); QModelIndex index2 = model.index(QDir::currentPath() + "/.qtest_hidden/qtest_visible"); QVERIFY(index2.isValid()); QDirModel model2; model2.setFilter(model2.filter() | QDir::Hidden); index = model2.index(QDir::currentPath() + "/.qtest_hidden"); QVERIFY(index.isValid()); #endif }
// TC_ID_3_x_3 : Call requestUpdate() with same value repeatedly void TestQGeoPositionInfoSource::requestUpdate_repeatedCalls() { CHECK_SOURCE_VALID; #if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) QSKIP("Real GPS not suitable for autotesting, skipping the test.", SkipAll); #endif QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&))); QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout())); m_source->requestUpdate(7000); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000); spyUpdate.clear(); m_source->requestUpdate(7000); EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000); }
void TestQGeoPositionInfoSource::startUpdates_moreThanOnce() { CHECK_SOURCE_VALID; #if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) QSKIP("Real GPS not suitable for autotesting, skipping the test.", SkipAll); #endif QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&))); QSignalSpy timeout(m_source, SIGNAL(updateTimeout())); m_source->setUpdateInterval(0); m_source->startUpdates(); m_source->startUpdates(); // check there is no crash EXPECT_FAIL_WINCE_SEE_MOBILITY_337; QTRY_VERIFY_WITH_TIMEOUT((spy.count() > 0) && (timeout.count() == 0), 7000); m_source->startUpdates(); // check there is no crash m_source->stopUpdates(); }
void tst_QCameraBackend::testCameraCaptureMetadata() { #ifndef Q_WS_MAEMO_6 QSKIP("Capture metadata is supported only on harmattan"); #endif QCamera camera; QCameraImageCapture imageCapture(&camera); camera.exposure()->setFlashMode(QCameraExposure::FlashOff); QSignalSpy metadataSignal(&imageCapture, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); QSignalSpy savedSignal(&imageCapture, SIGNAL(imageSaved(int,QString))); camera.start(); QTRY_VERIFY(imageCapture.isReadyForCapture()); int id = imageCapture.capture(QString::fromLatin1("/dev/null")); QTRY_VERIFY(!savedSignal.isEmpty()); QVERIFY(!metadataSignal.isEmpty()); QCOMPARE(metadataSignal.first().first().toInt(), id); }
void tst_QSocketNotifier::bogusFds() { #ifndef Q_OS_SYMBIAN //behaviour of QSocketNotifier with an invalid fd is totally different across OS //main point of this test was to check symbian backend doesn't crash QSKIP("test only for symbian", SkipAll); #else QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); QSocketNotifier max(std::numeric_limits<int>::max(), QSocketNotifier::Read); QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Invalid socket specified"); QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); QSocketNotifier min(std::numeric_limits<int>::min(), QSocketNotifier::Write); QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); //bogus magic number is the first pseudo socket descriptor from symbian socket engine. QSocketNotifier bogus(0x40000000, QSocketNotifier::Exception); QSocketNotifier largestlegal(FD_SETSIZE - 1, QSocketNotifier::Read); QSignalSpy maxspy(&max, SIGNAL(activated(int))); QSignalSpy minspy(&min, SIGNAL(activated(int))); QSignalSpy bogspy(&bogus, SIGNAL(activated(int))); QSignalSpy llspy(&largestlegal, SIGNAL(activated(int))); //generate some unrelated socket activity QTcpServer server; QVERIFY(server.listen(QHostAddress::LocalHost)); connect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop())); QTcpSocket client; client.connectToHost(QHostAddress::LocalHost, server.serverPort()); QTestEventLoop::instance().enterLoop(5); QVERIFY(server.hasPendingConnections()); //check no activity on bogus notifiers QCOMPARE(maxspy.count(), 0); QCOMPARE(minspy.count(), 0); QCOMPARE(bogspy.count(), 0); QCOMPARE(llspy.count(), 0); #endif }
void AnimenfoFetcherTest::testHachimitsu() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QLatin1String("AnimeNfo.com"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, "Hachimitsu to Clover"); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); // the first entry had better be the right one Tellico::Data::EntryPtr entry = results.at(0); QVERIFY(entry); QCOMPARE(entry->field("title"), QLatin1String("Hachimitsu to Clover")); QCOMPARE(entry->field("year"), QLatin1String("2005")); QCOMPARE(entry->field("episodes"), QLatin1String("26")); QCOMPARE(entry->field("keyword"), QLatin1String("TV")); QCOMPARE(entry->field("genre"), QLatin1String("Comedy; Drama; Romance")); QCOMPARE(entry->field("studio"), QLatin1String("J.C.STAFF")); QCOMPARE(entry->field("origtitle"), QString::fromUtf8("ハチミツとクローバー")); QCOMPARE(entry->field("director"), QString::fromUtf8("Kasai Kenichi (カサヰ ケンイチ)")); QCOMPARE(entry->field("writer"), QString::fromUtf8("Kuroda Yosuke (黒田洋介)")); QCOMPARE(entry->field("alttitle"), QLatin1String("Honey and Clover")); QCOMPARE(entry->field("animenfo-rating"), QLatin1String("9")); QVERIFY(entry->field("plot").startsWith(QLatin1String("Takemoto, Mayama, and Morita are students"))); QVERIFY(!entry->field("cover").isEmpty()); QVERIFY(!entry->field("animenfo").isEmpty()); QStringList castList = Tellico::FieldFormat::splitTable(entry->field("cast")); QCOMPARE(castList.count(), 7); QCOMPARE(castList.at(0), QString::fromUtf8("Kudo Haruka (工藤晴香)::Hanamoto Hagumi")); }
void tst_QUdpSocket::bindMode() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { #ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 explicit port binding is not supported.", SkipAll); } #endif } QUdpSocket socket; QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData()); QUdpSocket socket2; QVERIFY(!socket2.bind(socket.localPort())); #ifdef Q_OS_UNIX QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); socket.close(); QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData()); QVERIFY2(socket2.bind(socket.localPort()), socket2.errorString().toLatin1().constData()); socket2.close(); QVERIFY2(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData()); #else // Depending on the user's privileges, this or will succeed or // fail. Admins are allowed to reuse the address, but nobody else. if (!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData()) qWarning("Failed to bind with QUdpSocket::ReuseAddressHint, user isn't an adminstrator?"); socket.close(); QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData()); QVERIFY(!socket2.bind(socket.localPort())); socket.close(); QVERIFY2(socket.bind(0, QUdpSocket::DontShareAddress), socket.errorString().toLatin1().constData()); QVERIFY(!socket2.bind(socket.localPort())); QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); #endif }
// To avoid hitting the cache, we first set the icon to s_altIconUrl (ibm.com), // then back to s_iconUrl (kde.org) (to avoid messing up the favicons for the user ;) void FavIconTest::testSetIconForURL() { if ( !checkNetworkAccess() ) QSKIP( "no network access", SkipAll ); QSignalSpy spy( &m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)) ); QVERIFY( spy.isValid() ); QCOMPARE( spy.count(), 0 ); // The call to connect() triggers qdbus initialization stuff, while QSignalSpy doesn't... connect(&m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)), &m_eventLoop, SLOT(quit())); m_favIconModule.setIconForUrl( QString( s_hostUrl ), QString( s_altIconUrl ) ); qDebug( "called first setIconForUrl, waiting" ); if ( spy.count() < 1 ) { m_eventLoop.exec( QEventLoop::ExcludeUserInputEvents ); } QCOMPARE( spy.count(), 1 ); QCOMPARE( spy[0][0].toBool(), false ); QCOMPARE( spy[0][1].toString(), QString( s_hostUrl ) ); QCOMPARE( spy[0][2].toString(), QString( "favicons/www.ibm.com" ) ); m_favIconModule.setIconForUrl( QString( s_hostUrl ), QString( s_iconUrl ) ); qDebug( "called setIconForUrl again, waiting" ); if ( spy.count() < 2 ) { m_eventLoop.exec( QEventLoop::ExcludeUserInputEvents ); } QCOMPARE( spy.count(), 2 ); QCOMPARE( spy[1][0].toBool(), false ); QCOMPARE( spy[1][1].toString(), QString( s_hostUrl ) ); QCOMPARE( spy[1][2].toString(), QString( "favicons/www.google.com" ) ); disconnect(&m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)), &m_eventLoop, SLOT(quit())); }
void tst_QCommandLineParser::testQuoteEscaping() { #ifdef QT_NO_PROCESS QSKIP("This test requires QProcess support"); #else QCoreApplication app(empty_argc, empty_argv); QProcess process; process.start("testhelper/qcommandlineparser_test_helper", QStringList() << QString::number(QCommandLineParser::ParseAsCompactedShortOptions) << "\\\\server\\path" << "-DKEY1=\"VALUE1\"" "-DQTBUG-15379=C:\\path\\'file.ext" << "-DQTBUG-30628=C:\\temp\\'file'.ext"); QVERIFY(process.waitForFinished(5000)); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QString output = process.readAll(); QVERIFY2(!output.contains("ERROR"), qPrintable(output)); QVERIFY2(output.contains("\\\\server\\path"), qPrintable(output)); QVERIFY2(output.contains("KEY1=\"VALUE1\""), qPrintable(output)); QVERIFY2(output.contains("QTBUG-15379=C:\\path\\'file.ext"), qPrintable(output)); QVERIFY2(output.contains("QTBUG-30628=C:\\temp\\'file'.ext"), qPrintable(output)); #endif // !QT_NO_PROCESS }
void tst_QScriptEngineDebugger::debuggerSignals() { #if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); #endif QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); debugger.setAutoShowStandardWindow(false); QSignalSpy evaluationSuspendedSpy(&debugger, SIGNAL(evaluationSuspended())); QSignalSpy evaluationResumedSpy(&debugger, SIGNAL(evaluationResumed())); QObject::connect(&debugger, SIGNAL(evaluationSuspended()), debugger.action(QScriptEngineDebugger::ContinueAction), SLOT(trigger())); engine.evaluate("123"); QCOMPARE(evaluationSuspendedSpy.count(), 0); QCOMPARE(evaluationResumedSpy.count(), 0); engine.evaluate("debugger"); QCoreApplication::processEvents(); QCOMPARE(evaluationSuspendedSpy.count(), 1); QCOMPARE(evaluationResumedSpy.count(), 1); }
void FavIconTest::initTestCase() { QStandardPaths::setTestModeEnabled(true); // To avoid a runtime dependency on klauncher qputenv("KDE_FORK_SLAVES", "yes"); // To let ctest exit, we shouldn't start kio_http_cache_cleaner qputenv("KIO_DISABLE_CACHE_CLEANER", "yes"); // To get KJob::errorString() in English qputenv("LC_ALL", "en_US.UTF-8"); if (!checkNetworkAccess()) { QSKIP("no network access", SkipAll); } // Ensure we start with no cache on disk const QString favIconCacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QStringLiteral("/favicons"); QDir(favIconCacheDir).removeRecursively(); QVERIFY(!QFileInfo::exists(favIconCacheDir)); // Enable debug output QLoggingCategory::setFilterRules(QStringLiteral("kde.kio.favicons.debug=true")); }
void MoleculeFileTest::fileFormatDetectionWithCompression() { // check that gzip compression is supported std::vector<std::string> compressionFormats = chemkit::MoleculeFile::compressionFormats(); if(std::find(compressionFormats.begin(), compressionFormats.end(), "gz") == compressionFormats.end()){ QSKIP("Gzip compression not supported", SkipSingle); } // create empty file object chemkit::MoleculeFile file; // try to set an invalid file format bool ret = file.setFileName("ethanol.dml.gz"); // check return code and error string QVERIFY(ret == false); QCOMPARE(file.errorString().c_str(), "File format 'dml' is not supported."); // check file format and compression format QVERIFY(file.format() == 0); QCOMPARE(file.compressionFormat().c_str(), "gz"); // try to set a valid file format ret = file.setFileName("ethanol.cml.gz"); QVERIFY(file.format() != 0); // check file format and compression format QVERIFY(file.format() != 0); QCOMPARE(file.compressionFormat().c_str(), "gz"); // check return code QVERIFY(ret == true); }
//---------------------------------------------------------------------------------- void tst_QTcpServer::maxPendingConnections() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QSKIP("With socks5 only 1 connection is allowed ever", SkipAll); } } //### sees to fail sometimes ... a timing issue with the test on windows QTcpServer server; server.setMaxPendingConnections(2); QTcpSocket socket1; QTcpSocket socket2; QTcpSocket socket3; QVERIFY(server.listen()); socket1.connectToHost(QHostAddress::LocalHost, server.serverPort()); socket2.connectToHost(QHostAddress::LocalHost, server.serverPort()); socket3.connectToHost(QHostAddress::LocalHost, server.serverPort()); QVERIFY(server.waitForNewConnection(5000)); QVERIFY(server.hasPendingConnections()); QVERIFY(server.nextPendingConnection()); QVERIFY(server.hasPendingConnections()); QVERIFY(server.nextPendingConnection()); QVERIFY(!server.hasPendingConnections()); QCOMPARE(server.nextPendingConnection(), (QTcpSocket*)0); QVERIFY(server.waitForNewConnection(5000)); QVERIFY(server.hasPendingConnections()); QVERIFY(server.nextPendingConnection()); }
void tst_QWebEngineView::renderHints() { #if !defined(QWEBENGINEVIEW_RENDERHINTS) QSKIP("QWEBENGINEVIEW_RENDERHINTS"); #else QWebEngineView webView; // default is only text antialiasing + smooth pixmap transform QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::Antialiasing, true); QVERIFY(webView.renderHints() & QPainter::Antialiasing); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::Antialiasing, false); QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::SmoothPixmapTransform, true); QVERIFY(!(webView.renderHints() & QPainter::Antialiasing)); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform); QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); webView.setRenderHint(QPainter::SmoothPixmapTransform, false); QVERIFY(webView.renderHints() & QPainter::TextAntialiasing); QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform)); QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing)); #endif }
void tst_QProcessEnvironment::putenv() { #ifdef Q_OS_WINCE QSKIP("Windows CE has no environment"); #else static const char envname[] = "WE_RE_SETTING_THIS_ENVIRONMENT_VARIABLE"; static bool testRan = false; if (testRan) QFAIL("You cannot run this test more than once, since we modify the environment"); testRan = true; QByteArray valBefore = qgetenv(envname); if (!valBefore.isNull()) QFAIL("The environment variable we set in the environment is already set! -- please correct the test environment"); QProcessEnvironment eBefore = QProcessEnvironment::systemEnvironment(); qputenv(envname, "Hello, World"); QByteArray valAfter = qgetenv(envname); QCOMPARE(valAfter, QByteArray("Hello, World")); QProcessEnvironment eAfter = QProcessEnvironment::systemEnvironment(); QVERIFY(!eBefore.contains(envname)); QVERIFY(eAfter.contains(envname)); QCOMPARE(eAfter.value(envname), QString("Hello, World")); # ifdef Q_OS_WIN // check case-insensitive too QString lower = envname; lower = lower.toLower(); QVERIFY(!eBefore.contains(lower)); QVERIFY(eAfter.contains(lower)); QCOMPARE(eAfter.value(lower), QString("Hello, World")); # endif #endif }
void tst_QScriptEngineDebugger::action() { #if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); #endif QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); QList<QScriptEngineDebugger::DebuggerAction> actions; actions << QScriptEngineDebugger::InterruptAction << QScriptEngineDebugger::ContinueAction << QScriptEngineDebugger::StepIntoAction << QScriptEngineDebugger::StepOverAction << QScriptEngineDebugger::StepOutAction << QScriptEngineDebugger::RunToCursorAction << QScriptEngineDebugger::RunToNewScriptAction << QScriptEngineDebugger::ToggleBreakpointAction << QScriptEngineDebugger::ClearDebugOutputAction << QScriptEngineDebugger::ClearErrorLogAction << QScriptEngineDebugger::ClearConsoleAction << QScriptEngineDebugger::FindInScriptAction << QScriptEngineDebugger::FindNextInScriptAction << QScriptEngineDebugger::FindPreviousInScriptAction << QScriptEngineDebugger::GoToLineAction; QList<QAction*> lst; for (int i = 0; i < actions.size(); ++i) { QScriptEngineDebugger::DebuggerAction da = actions.at(i); QAction *act = debugger.action(da); QVERIFY(act != 0); QCOMPARE(act, debugger.action(da)); QCOMPARE(act->parent(), (QObject*)&debugger); QVERIFY(lst.indexOf(act) == -1); lst.append(act); } }
void tst_Q3PopupMenu::task177490_highlighted() { #ifdef Q_WS_MAC QSKIP("On Mac, native mouse events are needed for this test", SkipAll); #endif #ifdef Q_WS_QWS QApplication::processEvents(); #endif Q3PopupMenu menu1; menu1.insertItem("Item 1"); Q3PopupMenu menu2; menu2.insertItem("Item 2"); menu1.insertItem("Menu 2", &menu2); menu1.show(); const int y1 = menu1.itemGeometry(0).center().y(); const int y2 = menu1.itemGeometry(1).center().y(); const int x = menu1.itemGeometry(0).center().x(); QSignalSpy spy(&menu1, SIGNAL(highlighted(int))); QTest::mouseMove(&menu1, QPoint(x, y1)); QTest::mouseMove(&menu1, QPoint(x, y1 + 1)); QTest::qWait(1000); QTest::mouseMove(&menu1, QPoint(x, y2)); QTest::mouseMove(&menu1, QPoint(x, y2 + 1)); QTest::qWait(1000); if (!menu2.isVisible()) QEXPECT_FAIL( "", "expected failure due to visibilty/focus problem; to be investigated later", Abort); QCOMPARE(spy.count(), 2); // one per menu item }
void tst_QScriptEngine::gurmukhi() { { FT_Face face = loadFace("lohit_pa.ttf"); if (face) { const ShapeTable shape_table [] = { { { 0xA15, 0xA4D, 0xa39, 0x0 }, { 0x3b, 0x8b, 0x0 } }, { {0}, {0} } }; const ShapeTable *s = shape_table; while (s->unicode[0]) { QVERIFY( shaping(face, s, HB_Script_Gurmukhi) ); ++s; } FT_Done_Face(face); } else { QSKIP("couln't find lohit.punjabi.1.1.ttf"); } } }
void tst_QScriptEngine::linearB() { { FT_Face face = loadFace("penuture.ttf"); if (face) { const ShapeTable shape_table [] = { { { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 }, { 0x5, 0x6, 0x7, 0 } }, { {0}, {0} } }; const ShapeTable *s = shape_table; while (s->unicode[0]) { QVERIFY( shaping(face, s, HB_Script_Common) ); ++s; } FT_Done_Face(face); } else { QSKIP("couln't find PENUTURE.TTF"); } } }
void tst_MacNativeEvents::testChildDialogInFrontOfModalParent() { QSKIP("Modal dialog causes later tests to fail, see QTBUG-58474"); // Test that a child dialog of a modal parent dialog is // in front of the parent, and active: QDialog parent; parent.setWindowModality(Qt::ApplicationModal); QDialog child(&parent); QPushButton button("close", &child); connect(&button, SIGNAL(clicked()), &child, SLOT(close())); parent.show(); child.show(); QPoint inside = button.mapToGlobal(button.geometry().center()); // Post a click on the button to close the child dialog: NativeEventList native; native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 1, Qt::NoModifier)); native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 0, Qt::NoModifier)); native.play(); QTest::qWait(100); QVERIFY(!child.isVisible()); }
void tst_QDirModel::unreadable() { #ifndef Q_OS_UNIX QSKIP("Test not implemented on non-Unixes"); #else // Create an empty file which has no read permissions (file will be removed by cleanup()). QFile unreadableFile(QDir::currentPath() + "qtest_unreadable"); QVERIFY2(unreadableFile.open(QIODevice::WriteOnly | QIODevice::Text), qPrintable(unreadableFile.errorString())); unreadableFile.close(); QVERIFY(unreadableFile.exists()); QVERIFY2(unreadableFile.setPermissions(QFile::WriteOwner), qPrintable(unreadableFile.errorString())); // Check that we can't make a valid model index from an unreadable file. QDirModel model; QModelIndex index = model.index(QDir::currentPath() + "/qtest_unreadable"); QVERIFY(!index.isValid()); // Check that unreadable files are not treated like hidden files. QDirModel model2; model2.setFilter(model2.filter() | QDir::Hidden); index = model2.index(QDir::currentPath() + "/qtest_unreadable"); QVERIFY(!index.isValid()); #endif }
void tst_QXml::exception() { #ifndef QT_NO_EXCEPTIONS QString message = QString::fromLatin1("message"); int column = 3; int line = 2; QString publicId = QString::fromLatin1("publicId"); QString systemId = QString::fromLatin1("systemId"); try { QXmlParseException e(message, column, line, publicId, systemId); throw e; } catch (QXmlParseException e) { QCOMPARE(e.message(), message); QCOMPARE(e.columnNumber(), column); QCOMPARE(e.lineNumber(), line); QCOMPARE(e.publicId(), publicId); QCOMPARE(e.systemId(), systemId); } #else QSKIP("Exceptions not available", SkipAll); #endif }
void Ut_MListNewView::testPerformance() { QSKIP("currently doesn't work", SkipSingle); listViewPrivate->viewportTopLeft = QPoint(0, 0); listViewPrivate->viewportVisibleHeight = 800; for (int i = 0; i < 10; i++) { if (i % 1 == 0) listViewPrivate->viewportTopLeft = QPoint(0, 0); else listViewPrivate->viewportTopLeft = QPoint(0, 800); QModelIndex firstVisibleRow = listViewPrivate->locateVisibleIndexAt(listViewPrivate->viewportTopLeft.y()); listViewPrivate->updateFirstVisibleRow(firstVisibleRow); QModelIndex lastVisibleRow = listViewPrivate->locateVisibleIndexAt(listViewPrivate->viewportTopLeft.y() + listViewPrivate->viewportVisibleHeight); listViewPrivate->updateLastVisibleRow(lastVisibleRow); QPoint firstVisibleItemPos(0, listViewPrivate->locatePosOfItem(firstVisibleRow)); QPoint lastVisibleItemPos(0, listViewPrivate->locatePosOfItem(lastVisibleRow)); listViewPrivate->removeInvisibleItems(firstVisibleItemPos, lastVisibleItemPos); if (listViewPrivate->model->rowCount() > 0) listViewPrivate->createVisibleItems(firstVisibleRow, lastVisibleRow); } }
void TestDPPlugin::test_desktops() { if (!m_isKwinActive) QSKIP("KWin inactive, skip Destkop panel tests"); int current = plugin->currentDesktop(); int total = plugin->numberOfDesktops(); QVERIFY(total != 0); QVERIFY(current <= total); int number; if (total == 1) number = current; else number = current == (total - 1) ? current - 1 : current + 1; QSignalSpy spy(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int))); plugin->setCurrentDesktop(number); QVERIFY(spy.wait(5000)); QCOMPARE(plugin->currentDesktop(), number); plugin->setCurrentDesktop(current); QVERIFY(spy.wait(5000)); QCOMPARE(plugin->currentDesktop(), current); }
void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop() { #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) QSKIP("Not supported on Android"); #endif // based on testcase provided in QTBUG-39488 QByteArray msg = "Hello World"; QProcess process; process.start("write-read-write/write-read-write", QStringList() << msg); QVERIFY(process.waitForStarted(5000)); QVERIFY(process.waitForReadyRead(5000)); QCOMPARE(process.readAll().trimmed(), msg); // run the GUI event dispatcher once QSignalSpy spy(&process, SIGNAL(readyRead())); qApp->processEvents(QEventLoop::AllEvents, 100); // we mustn't have read anything in the event loop QCOMPARE(spy.count(), 0); // ensure the process hasn't died QVERIFY(!process.waitForFinished(250)); // we mustn't have read anything during waitForFinished either QCOMPARE(spy.count(), 0); // release the child for the second write process.write("\n"); QVERIFY(process.waitForFinished(5000)); QCOMPARE(int(process.exitStatus()), int(QProcess::NormalExit)); QCOMPARE(process.exitCode(), 0); QCOMPARE(spy.count(), 1); QCOMPARE(process.readAll().trimmed(), msg); }
void tst_QCameraBackend::testExposureMode() { #if !defined(Q_WS_MAEMO_6) QSKIP("Capture exposure parameters are supported only on mobile platforms"); #endif QCamera camera; QCameraExposure *exposure = camera.exposure(); #ifdef Q_WS_MAEMO_6 QEXPECT_FAIL("", "Camerabin reports Manual exposure instead of Auto", Continue); #endif QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureAuto); // Night exposure->setExposureMode(QCameraExposure::ExposureNight); QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureNight); camera.start(); QTRY_COMPARE(camera.status(), QCamera::ActiveStatus); QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureNight); camera.unload(); QTRY_COMPARE(camera.status(), QCamera::UnloadedStatus); #ifdef Q_WS_MAEMO_6 //resource policy doesn't work correctly when resource is released and immediately requested again. QTest::qWait(250); #endif // Auto exposure->setExposureMode(QCameraExposure::ExposureAuto); QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureAuto); camera.start(); QTRY_COMPARE(camera.status(), QCamera::ActiveStatus); QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureAuto); }