本文整理汇总了C++中ModelWatcher::waitForSignals方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelWatcher::waitForSignals方法的具体用法?C++ ModelWatcher::waitForSignals怎么用?C++ ModelWatcher::waitForSignals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelWatcher
的用法示例。
在下文中一共展示了ModelWatcher::waitForSignals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modifyEvent
void ConversationModelTest::modifyEvent()
{
ConversationModel model;
model.enableContactChanges(false);
watcher.setModel(&model);
model.setQueryMode(EventModel::SyncQuery);
QVERIFY(model.getEvents(group1.id()));
Event event;
/* modify invalid event */
QVERIFY(!model.modifyEvent(event));
QVERIFY(model.rowCount() > 0);
int row = rand() % model.rowCount();
event = model.event(model.index(row, 0));
qDebug() << row << event.id() << event.freeText();
event.setFreeText("modified event");
QDateTime modified = event.lastModified();
QVERIFY(model.modifyEvent(event));
watcher.waitForSignals();
QVERIFY(model.trackerIO().getEvent(event.id(), event));
QCOMPARE(event.freeText(), QString("modified event"));
QSKIP("Make nie:contentLastUpdated handling consistent", SkipSingle);
event = model.event(model.index(row, 0));
QCOMPARE(event.freeText(), QString("modified event"));
QVERIFY(event.lastModified() > modified);
}
示例2: addEvent
void UnreadEventModelTest::addEvent()
{
UnreadEventsModel model;
watcher.setModel(&model);
model.setQueryMode(EventModel::SyncQuery);
GroupModel groupModel;
groupModel.enableContactChanges(false);
group1.setLocalUid("/org/freedesktop/Telepathy/Account/gabble/jabber/dut_40localhost0");
QStringList uids;
uids << "[email protected]";
group1.setRemoteUids(uids);
QVERIFY(groupModel.addGroup(group1));
for (int j = 0; j < NUM_EVENTS; j++) {
Event e;
Event dbEvent;
int id;
e = createEvent("[email protected]");
e.setGroupId(group1.id());
QVERIFY(model.addEvent(e));
watcher.waitForSignals();
id = e.id();
QVERIFY(id != -1);
QVERIFY(model.trackerIO().getEvent(id, dbEvent));
QCOMPARE(dbEvent.id(), id);
}
}
示例3: modifyEvent
bool SyncModelTest::modifyEvent( int itemId, int parentId, int groupId, const QDateTime &lastModTime,
const QString& localId, const QString& remoteId, const QString& text, bool read)
{
Q_UNUSED(lastModTime);
EventModel model;
watcher.setModel(&model);
Event e;
e.setType(Event::SMSEvent);
e.setId(itemId);
e.setParentId(parentId);
if (parentId == ::INBOX || parentId >= ::MYFOLDER) {
e.setDirection(Event::Inbound);
} else {
e.setDirection(Event::Outbound);
}
e.setGroupId(groupId);
e.setLocalUid(localId);
e.setRemoteUid(remoteId);
e.setFreeText(text);
e.setIsRead(read);
bool ret = model.modifyEvent(e);
watcher.waitForSignals(1, 1);
return ret;
}
示例4: addEvent
//Private functions
bool SyncModelTest::addEvent(int parentId, int groupId, const QDateTime& sentReceivedTime,
const QString& localId, const QString& remoteId, const QString& text, bool read)
{
EventModel model;
watcher.setModel(&model);
Event e;
e.setType(Event::SMSEvent);
e.setParentId(parentId);
if (parentId == ::INBOX || parentId >= ::MYFOLDER) {
e.setDirection(Event::Inbound);
} else {
e.setDirection(Event::Outbound);
}
e.setGroupId(groupId);
e.setStartTime(sentReceivedTime);
e.setEndTime(sentReceivedTime);
e.setLocalUid(localId);
e.setRemoteUid(remoteId);
e.setFreeText(text);
e.setIsRead(read);
bool ret_val = model.addEvent(e);
watcher.waitForSignals(1, 1);
itemId = e.id();
return ret_val;
}
示例5: deleteEvents
void ClassZeroSMSModelTest::deleteEvents()
{
while(m_pModel->rowCount()) {
Event event = m_pModel->event(m_pModel->index(0, 0));
QVERIFY(event.id() != -1);
m_pModel->deleteEvent(event.id());
watcher.waitForSignals(-1, 1);
}
QVERIFY( m_pModel->rowCount() == 0);
}
示例6: contactMatching
void SingleEventModelTest::contactMatching()
{
QFETCH(QString, localId);
QFETCH(QString, remoteId);
QFETCH(int, eventType);
SingleEventModel model;
Event::PropertySet p;
p.insert(Event::ContactId);
p.insert(Event::ContactName);
model.setPropertyMask(p);
watcher.setModel(&model);
int eventId = addTestEvent(model, (Event::EventType)eventType, Event::Inbound, localId, group1.id(),
"text", false, false, QDateTime::currentDateTime(), remoteId);
watcher.waitForSignals();
QVERIFY(eventId != -1);
QVERIFY(model.getEventByUri(Event::idToUrl(eventId)));
QVERIFY(watcher.waitForModelReady());
Event event = model.event(model.index(0, 0));
QCOMPARE(event.id(), eventId);
QCOMPARE(event.contactId(), 0);
QString noMatch = remoteId;
noMatch += remoteId[1];
int contactId1 = addTestContact("Really1Bad",
noMatch,
localId);
QVERIFY(model.getEventByUri(Event::idToUrl(eventId)));
QVERIFY(watcher.waitForModelReady());
event = model.event(model.index(0, 0));
QCOMPARE(event.id(), eventId);
QCOMPARE(event.contactId(), 0);
int contactId = addTestContact("Really Bad", remoteId, localId);
QVERIFY(model.getEventByUri(Event::idToUrl(eventId)));
QVERIFY(watcher.waitForModelReady());
event = model.event(model.index(0, 0));
QCOMPARE(event.id(), eventId);
QCOMPARE(event.contactId(), contactId);
QCOMPARE(event.contactName(), QString("Really Bad"));
deleteTestContact(contactId1);
deleteTestContact(contactId);
}
示例7: addEvent
void ClassZeroSMSModelTest::addEvent()
{
for (int j = 0; j < NUM_EVENTS; j++) {
Event e;
int id;
e = createEvent();
QVERIFY(m_pModel->addEvent(e,true));
id = e.id();
QVERIFY(id != -1);
watcher.waitForSignals(-1, 1);
QCOMPARE(watcher.addedCount(), 1);
}
}
示例8: markAsRead
void UnreadEventModelTest::markAsRead()
{
UnreadEventsModel model;
watcher.setModel(&model);
model.setQueryMode(EventModel::SyncQuery);
model.getEvents();
const int count = model.rowCount();
QList<Event> events;
for (int i = 0; i < count; i++) {
Event event = model.event(model.index(count-1-i, 0));
event.setIsRead(true);
events << event;
}
model.modifyEvents(events);
if (count) watcher.waitForSignals();
QVERIFY(model.rowCount() == 0);
}
示例9: initTestCase
void ConversationModelTest::initTestCase()
{
QVERIFY(QDBusConnection::sessionBus().isConnected());
deleteAll();
loop = new QEventLoop(this);
watcher.setLoop(loop);
qsrand(QDateTime::currentDateTime().toTime_t());
addTestGroups(group1, group2);
EventModel model;
watcher.setModel(&model);
addTestEvent(model, Event::IMEvent, Event::Inbound, ACCOUNT1, group1.id());
addTestEvent(model, Event::IMEvent, Event::Inbound, ACCOUNT1, group1.id());
addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT1, group1.id());
addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT1, group1.id());
addTestEvent(model, Event::IMEvent, Event::Inbound, ACCOUNT2, group1.id());
addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT2, group1.id());
addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1, group1.id());
addTestEvent(model, Event::SMSEvent, Event::Outbound, ACCOUNT1, group1.id());
addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT2, group1.id());
addTestEvent(model, Event::SMSEvent, Event::Outbound, ACCOUNT2, group1.id());
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1);
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1);
addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT1, group1.id(),
"draft", true);
// status message:
// NOTE: this event is not visible in any of the further tests
addTestEvent(model, Event::StatusMessageEvent, Event::Outbound, ACCOUNT1,
group1.id(), "statue message", false, false,
QDateTime::currentDateTime(), QString(), true);
watcher.waitForSignals(13, 14);
}
示例10: sorting
void ConversationModelTest::sorting()
{
EventModel model;
model.setQueryMode(EventModel::StreamedAsyncQuery);
model.setFirstChunkSize(5);
model.enableContactChanges(false);
watcher.setModel(&model);
//add events with the same timestamp
QDateTime now = QDateTime::currentDateTime();
QDateTime future = now.addSecs(10);
addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
group1.id(), "I", false, false, now);
addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
group1.id(), "II", false, false, now);
addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
group1.id(), "III", false, false, future);
addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
group1.id(), "IV", false, false, future);
addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
group1.id(), "V", false, false, future);
watcher.waitForSignals(5, 5);
ConversationModel conv;
conv.setQueryMode(EventModel::StreamedAsyncQuery);
conv.setFirstChunkSize(5);
conv.enableContactChanges(false);
QSignalSpy rowsInserted(&conv, SIGNAL(rowsInserted(const QModelIndex &, int, int)));
QVERIFY(conv.getEvents(group1.id()));
QVERIFY(waitSignal(rowsInserted));
QVERIFY(conv.rowCount() >= 5 );
QCOMPARE(conv.event(conv.index(0, 0)).freeText(), QLatin1String("V"));
QCOMPARE(conv.event(conv.index(1, 0)).freeText(), QLatin1String("IV"));
QCOMPARE(conv.event(conv.index(2, 0)).freeText(), QLatin1String("III"));
QCOMPARE(conv.event(conv.index(3, 0)).freeText(), QLatin1String("II"));
QCOMPARE(conv.event(conv.index(4, 0)).freeText(), QLatin1String("I"));
}
示例11: deleteEvent
void ConversationModelTest::deleteEvent()
{
ConversationModel model;
model.enableContactChanges(false);
watcher.setModel(&model);
model.setQueryMode(EventModel::SyncQuery);
QVERIFY(model.getEvents(group1.id()));
Event event;
/* delete invalid event */
QVERIFY(!model.deleteEvent(event));
int rows = model.rowCount();
int row = rand() % rows;
event = model.event(model.index(row, 0));
qDebug() << row << event.id();
QVERIFY(model.deleteEvent(event.id()));
watcher.waitForSignals();
QVERIFY(!model.trackerIO().getEvent(event.id(), event));
QVERIFY(model.event(model.index(row, 0)).id() != event.id());
QVERIFY(model.rowCount() == rows - 1);
}
示例12: getEventByUri
void SingleEventModelTest::getEventByUri()
{
SingleEventModel model;
watcher.setModel(&model);
Event event;
event.setType(Event::SMSEvent);
event.setDirection(Event::Outbound);
event.setLocalUid("/org/freedesktop/Telepathy/Account/gabble/jabber/dut_40localhost0");
event.setGroupId(group1.id());
event.setFreeText("freeText");
event.setStartTime(QDateTime::currentDateTime());
event.setEndTime(QDateTime::currentDateTime());
event.setRemoteUid("123456");
event.setMessageToken("messageTokenA1");
// ignore call properties
Event::PropertySet p = Event::allProperties();
p.remove(Event::IsEmergencyCall);
p.remove(Event::IsMissedCall);
model.setPropertyMask(p);
//TODO: add reading invalid id
QVERIFY(model.addEvent(event));
watcher.waitForSignals();
QVERIFY(event.id() != -1);
QVERIFY(model.getEventByUri(event.url()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
Event modelEvent = model.event(model.index(0, 0));
QVERIFY(compareEvents(event, modelEvent));
}
示例13: getEventByTokens
void SingleEventModelTest::getEventByTokens()
{
SingleEventModel model;
// ignore call properties
Event::PropertySet p = Event::allProperties();
p.remove(Event::IsEmergencyCall);
p.remove(Event::IsMissedCall);
model.setPropertyMask(p);
watcher.setModel(&model);
Event event;
event.setType(Event::SMSEvent);
event.setDirection(Event::Outbound);
event.setLocalUid("/org/freedesktop/Telepathy/Account/gabble/jabber/dut_40localhost0");
event.setGroupId(group1.id());
event.setFreeText("freeText");
event.setStartTime(QDateTime::currentDateTime());
event.setEndTime(QDateTime::currentDateTime());
event.setRemoteUid("123456");
event.setMessageToken("messageTokenB1");
QVERIFY(model.addEvent(event));
watcher.waitForSignals();
QVERIFY(event.id() != -1);
Event mms(event);
mms.setMessageToken("mmsMessageToken");
mms.setMmsId("mmsId");
QVERIFY(model.addEvent(mms));
watcher.waitForSignals();
QVERIFY(mms.id() != -1);
Event mms2(event);
mms2.setMessageToken("mmsMessageToken");
mms2.setMmsId("mmsId");
mms2.setGroupId(group2.id());
QVERIFY(model.addEvent(mms2));
watcher.waitForSignals();
QVERIFY(mms2.id() != -1);
QVERIFY(model.getEventByTokens("messageTokenB1", "", -1));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
Event modelEvent = model.event(model.index(0, 0));
QVERIFY(compareEvents(event, modelEvent));
QVERIFY(model.getEventByTokens("messageTokenB1", "", group1.id()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
modelEvent = model.event(model.index(0, 0));
QVERIFY(compareEvents(event, modelEvent));
QVERIFY(model.getEventByTokens("messageTokenB1", "", group1.id() + 1));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 0);
// Can match either to token or mms id:
QVERIFY(model.getEventByTokens("messageTokenB1", "nonExistingMmsId", group1.id()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
modelEvent = model.event(model.index(0, 0));
QVERIFY(compareEvents(event, modelEvent));
QVERIFY(model.getEventByTokens("", "nonExistingMmsId", group1.id()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 0);
QVERIFY(model.getEventByTokens("", "mmsId", group1.id()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
modelEvent = model.event(model.index(0, 0));
QVERIFY(compareEvents(mms, modelEvent));
QVERIFY(model.getEventByTokens("", "mmsId", group2.id()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
modelEvent = model.event(model.index(0, 0));
QVERIFY(compareEvents(mms2, modelEvent));
QVERIFY(model.getEventByTokens("mmsMessageToken", "mmsId", group1.id()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
//.........这里部分代码省略.........
示例14: updateStatus
void SingleEventModelTest::updateStatus()
{
SingleEventModel model;
watcher.setModel(&model);
SingleEventModel observer;
ModelWatcher watcherObserver;
watcherObserver.setModel(&observer);
Event event;
event.setType(Event::SMSEvent);
event.setDirection(Event::Outbound);
event.setLocalUid("/org/freedesktop/Telepathy/Account/gabble/jabber/dut_40localhost0");
event.setGroupId(group1.id());
event.setFreeText("freeText");
event.setStartTime(QDateTime::currentDateTime());
event.setEndTime(QDateTime::currentDateTime());
event.setRemoteUid("123456");
event.setMessageToken("messageTokenB");
QVERIFY(model.addEvent(event));
watcher.waitForSignals();
QVERIFY(event.id() != -1);
CommHistory::Event::PropertySet props = CommHistory::Event::PropertySet()
<< CommHistory::Event::Id
<< CommHistory::Event::Direction
<< CommHistory::Event::Status
<< CommHistory::Event::GroupId
<< CommHistory::Event::MessageToken
<< CommHistory::Event::ReportDelivery
<< CommHistory::Event::MmsId;
model.setPropertyMask(props);
QVERIFY(model.getEventByUri(event.url()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
Event modelEvent = model.event(model.index(0, 0));
QVERIFY(modelEvent.validProperties().contains(CommHistory::Event::Status));
QVERIFY(modelEvent.validProperties().contains(CommHistory::Event::MessageToken));
QVERIFY(!modelEvent.validProperties().contains(CommHistory::Event::FreeText));
QVERIFY(!modelEvent.validProperties().contains(CommHistory::Event::ContactId));
QCOMPARE(event.status(), modelEvent.status());
QCOMPARE(event.messageToken(), modelEvent.messageToken());
// init observer model with the same event and all properties
QVERIFY(observer.getEventByUri(event.url()));
QVERIFY(watcherObserver.waitForModelReady());
QCOMPARE(observer.rowCount(), 1);
Event observedEvent = observer.event(observer.index(0, 0));
QVERIFY(compareEvents(event, observedEvent));
// modify event with new status only
modelEvent.setStatus(Event::SentStatus);
QVERIFY(model.modifyEvent(modelEvent));
watcher.waitForSignals();
QCOMPARE(watcher.updatedCount(), 1);
QCOMPARE(watcher.committedCount(), 1);
//check observer model
QTest::qWait(100);
observedEvent = observer.event(observer.index(0, 0));
QCOMPARE(observedEvent.freeText(), event.freeText());
QCOMPARE(observedEvent.status(), Event::SentStatus);
}
示例15: getEvents
void ConversationModelTest::getEvents()
{
QFETCH(bool, useThread);
QThread modelThread;
ConversationModel model;
model.enableContactChanges(false);
watcher.setModel(&model);
if (useThread) {
modelThread.start();
model.setBackgroundThread(&modelThread);
}
QVERIFY(model.getEvents(group1.id()));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 10);
for (int i = 0; i < model.rowCount(); i++) {
Event e1, e2;
QModelIndex ind = model.index(i, 0);
e1 = model.event(ind);
QVERIFY(model.trackerIO().getEvent(e1.id(), e2));
QVERIFY(compareEvents(e1, e2));
QVERIFY(model.event(ind).type() != Event::CallEvent);
}
// add but don't save status message and check content again
addTestEvent(model, Event::StatusMessageEvent, Event::Outbound, ACCOUNT1,
group1.id(), "status message", false, false,
QDateTime::currentDateTime(), QString(), true);
watcher.waitForSignals(-1, 1);
QCOMPARE(model.rowCount(), 11);
for (int i = 0; i < model.rowCount(); i++)
QVERIFY(model.event(model.index(i, 0)).type() != Event::CallEvent);
// NOTE: since setFilter re-fetches data from tracker, status message event is lost
/* filtering by type */
QVERIFY(model.setFilter(Event::IMEvent));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 6);
for (int i = 0; i < model.rowCount(); i++)
QCOMPARE(model.event(model.index(i, 0)).type(), Event::IMEvent);
QVERIFY(model.setFilter(Event::SMSEvent));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 4);
for (int i = 0; i < model.rowCount(); i++)
QCOMPARE(model.event(model.index(i, 0)).type(), Event::SMSEvent);
/* filtering by account */
QVERIFY(model.setFilter(Event::UnknownType, ACCOUNT1));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 6);
for (int i = 0; i < model.rowCount(); i++)
QCOMPARE(model.event(model.index(i, 0)).localUid(), ACCOUNT1);
QVERIFY(model.setFilter(Event::UnknownType, ACCOUNT2));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 4);
for (int i = 0; i < model.rowCount(); i++)
QCOMPARE(model.event(model.index(i, 0)).localUid(), ACCOUNT2);
/* filtering by direction */
QVERIFY(model.setFilter(Event::UnknownType, QString(), Event::Inbound));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 5);
for (int i = 0; i < model.rowCount(); i++)
QCOMPARE(model.event(model.index(i, 0)).direction(), Event::Inbound);
QVERIFY(model.setFilter(Event::UnknownType, QString(), Event::Outbound));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 5);
for (int i = 0; i < model.rowCount(); i++)
QCOMPARE(model.event(model.index(i, 0)).direction(), Event::Outbound);
/* mixed filtering */
QVERIFY(model.setFilter(Event::IMEvent, ACCOUNT1, Event::Outbound));
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 2);
for (int i = 0; i < model.rowCount(); i++) {
QCOMPARE(model.event(model.index(i, 0)).type(), Event::IMEvent);
QCOMPARE(model.event(model.index(i, 0)).localUid(), ACCOUNT1);
QCOMPARE(model.event(model.index(i, 0)).direction(), Event::Outbound);
}
modelThread.quit();
modelThread.wait(3000);
}