tests/auto/qdbusperformance/tst_qdbusperformance.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    78 };
    78 };
    79 Q_DECLARE_METATYPE(QVariant)
    79 Q_DECLARE_METATYPE(QVariant)
    80 
    80 
    81 void tst_QDBusPerformance::initTestCase()
    81 void tst_QDBusPerformance::initTestCase()
    82 {
    82 {
       
    83     QDBusConnection con = QDBusConnection::sessionBus();
       
    84     QVERIFY(con.isConnected());
       
    85 
       
    86     QDBusServiceWatcher watcher(serviceName, con,
       
    87                                 QDBusServiceWatcher::WatchForRegistration);
       
    88     connect(&watcher, SIGNAL(serviceRegistered(QString)),
       
    89             &QTestEventLoop::instance(), SLOT(exitLoop()));
       
    90 
    83 #ifdef Q_OS_WIN
    91 #ifdef Q_OS_WIN
    84     proc.start("server");
    92     proc.start("server");
    85 #else
    93 #else
    86     proc.start("./server/server");
    94     proc.start("./server/server");
    87 #endif
    95 #endif
    88     QVERIFY(proc.waitForStarted());
    96     QVERIFY(proc.waitForStarted());
    89 
    97 
    90     QDBusConnection con = QDBusConnection::sessionBus();
    98     QTestEventLoop::instance().enterLoop(5);
    91     QVERIFY(con.isConnected());
       
    92 
       
    93     connect(con.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
       
    94             &QTestEventLoop::instance(), SLOT(exitLoop()));
       
    95     QTime timer;
       
    96     timer.start();
       
    97 
       
    98     while (timer.elapsed() < 5000) {
       
    99         QTestEventLoop::instance().enterLoop(5);
       
   100         if (con.interface()->isServiceRegistered(serviceName))
       
   101             break;
       
   102     }
       
   103     QVERIFY(con.interface()->isServiceRegistered(serviceName));
    99     QVERIFY(con.interface()->isServiceRegistered(serviceName));
   104 
   100 
   105     remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this);
   101     remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this);
   106     QVERIFY(remote->isValid());
   102     QVERIFY(remote->isValid());
   107 
   103