void tst_QTimer::recurringTimer() { const int target = 5; QFETCH(int, interval); { RecurringTimerObject object(target); QObject::connect(&object, SIGNAL(done()), &QTestEventLoop::instance(), SLOT(exitLoop())); (void) object.startTimer(interval); QTestEventLoop::instance().enterLoop(5); QCOMPARE(object.times, target); } { // make sure that eventloop recursion doesn't effect timer recurrance RecurringTimerObject object(target); object.recurse = true; QObject::connect(&object, SIGNAL(done()), &QTestEventLoop::instance(), SLOT(exitLoop())); (void) object.startTimer(interval); QTestEventLoop::instance().enterLoop(5); QCOMPARE(object.times, target); } }
void tst_QDBusPerformance::initTestCase() { QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration); connect(&watcher, SIGNAL(serviceRegistered(QString)), &QTestEventLoop::instance(), SLOT(exitLoop())); #ifdef Q_OS_WIN proc.start("server"); #else proc.start("./server/server"); #endif QVERIFY(proc.waitForStarted()); QTestEventLoop::instance().enterLoop(5); QVERIFY(con.interface()->isServiceRegistered(serviceName)); remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this); QVERIFY(remote->isValid()); new ServerObject("/", con, this); local = new QDBusInterface(con.baseService(), "/", "com.trolltech.autotests.Performance", con, this); QVERIFY(local->isValid()); }
void JobRemoteTest::enterLoop() { QEventLoop eventLoop; connect(this, SIGNAL(exitLoop()), &eventLoop, SLOT(quit())); eventLoop.exec(QEventLoop::ExcludeUserInputEvents); }
static bool waitForDone(QDnsLookup *lookup) { if (lookup->isFinished()) return true; QObject::connect(lookup, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); QTestEventLoop::instance().enterLoop(10); return !QTestEventLoop::instance().timeout(); }
void tst_QTimer::deleteLaterOnQTimer() { QTimer *timer = new QTimer; connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); connect(timer, SIGNAL(destroyed()), &QTestEventLoop::instance(), SLOT(exitLoop())); timer->setInterval(1); timer->setSingleShot(true); timer->start(); QPointer<QTimer> pointer = timer; QTestEventLoop::instance().enterLoop(5); QVERIFY(pointer.isNull()); }
void tst_QDnsLookup_Appless::recreateApplication() { int argc = 0; char **argv = 0; for (int i = 0; i < 10; ++i) { QCoreApplication app(argc, argv); QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org"); dns.lookup(); if (!dns.isFinished()) { QObject::connect(&dns, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); QTestEventLoop::instance().enterLoop(10); } QVERIFY(dns.isFinished()); } }
void tst_qhttpnetworkconnection::bigRemoteFile() { QNetworkAccessManager manager; qint64 size; QTime t; QNetworkRequest request(QUrl("http://nds1.nokia.com/files/support/global/phones/software/Nokia_Ovi_Suite_webinstaller.exe")); QNetworkReply* reply = manager.get(request); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); qDebug() << "Starting download"; t.start(); QTestEventLoop::instance().enterLoop(50); QVERIFY(!QTestEventLoop::instance().timeout()); size = reply->size(); delete reply; qDebug() << "Finished!" << endl; qDebug() << "Time:" << t.elapsed() << "msec"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (size / 1024) / (t.elapsed() / 1000) << "KB/sec"; }
void tst_qhttpnetworkconnection::bigRemoteFile() { QNetworkAccessManager manager; qint64 size; QTime t; QNetworkRequest request(QUrl(QString::fromLatin1(urlC))); QNetworkReply* reply = manager.get(request); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); qDebug() << "Starting download" << urlC; t.start(); QTestEventLoop::instance().enterLoop(50); QVERIFY(!QTestEventLoop::instance().timeout()); size = reply->size(); delete reply; qDebug() << "Finished!" << endl; qDebug() << "Time:" << t.elapsed() << "msec"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (size / qreal(1024)) / (t.elapsed() / qreal(1000)) << "KB/sec"; }
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 testAdoptedThreadStorageWin(void *p) { QThreadStorage<Pointer *> *pointers = reinterpret_cast<QThreadStorage<Pointer *> *>(p); if (pointers->hasLocalData()) { threadStorageOk = false; return; } Pointer *pointer = new Pointer(); pointers->setLocalData(pointer); if (pointers->hasLocalData() == false) { threadStorageOk = false; return; } if (pointers->localData() != pointer) { threadStorageOk = false; return; } QObject::connect(QThread::currentThread(), SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); }
void JobRemoteTest::slotResult( KJob* job ) { m_result = job->error(); emit exitLoop(); }
void JobRemoteTest::slotGetResult( KJob* job ) { m_result = job->error(); m_data = static_cast<KIO::StoredTransferJob *>(job)->data(); emit exitLoop(); }