本文整理汇总了C++中ModelWatcher::waitForAdded方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelWatcher::waitForAdded方法的具体用法?C++ ModelWatcher::waitForAdded怎么用?C++ ModelWatcher::waitForAdded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelWatcher
的用法示例。
在下文中一共展示了ModelWatcher::waitForAdded方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTestCase
void CallModelTest::initTestCase()
{
QVERIFY( QDBusConnection::sessionBus().isConnected() );
deleteAll();
qsrand( QDateTime::currentDateTime().toTime_t() );
addTestGroups( group1, group2 );
// add 8 call events from user1
int cnt = 0;
QDateTime when = QDateTime::currentDateTime();
EventModel model;
watcher.setModel(&model);
// 2 dialed
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when, REMOTEUID1 ); cnt++;
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs( 5 ), REMOTEUID1 ); cnt++;
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::DialedCallType, 2 ) );
// 1 missed
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs( 10 ), REMOTEUID1 ); cnt++;
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::MissedCallType, 1 ) );
// 2 received
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 15 ), REMOTEUID1 ); cnt++;
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 20 ), REMOTEUID1 ); cnt++;
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::ReceivedCallType, 2 ) );
// 1 dialed
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs( 25 ), REMOTEUID1 ); cnt++;
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::DialedCallType, 1 ) );
// 2 missed
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs( 30 ), REMOTEUID1 ); cnt++;
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs( 35 ), REMOTEUID1 ); cnt++;
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::MissedCallType, 2 ) );
// add 1 im and 2 sms events
addTestEvent( model, Event::IMEvent, Event::Outbound, ACCOUNT1, group1.id(), "test" ); cnt++;
addTestEvent( model, Event::SMSEvent, Event::Inbound, ACCOUNT1, group1.id(), "test" ); cnt++;
addTestEvent( model, Event::SMSEvent, Event::Outbound, ACCOUNT1, group2.id(), "draft", true ); cnt++;
QVERIFY(watcher.waitForAdded(cnt));
}
示例2: testMinimizedPhone
// Make sure that phone numbers resolve to the right contacts even if they
// minimize to the same number.
void CallModelTest::testMinimizedPhone()
{
QSKIP("Contact matching is not yet supported with SQLite");
deleteAll();
const QString phone00("0011112222");
const QString phone99("9911112222");
// Precondition for the test:
QCOMPARE(minimizePhoneNumber(phone00), minimizePhoneNumber(phone99)); // enum { DefaultMaximumPhoneNumberCharacters = 8 }
const QString user00("User00");
const QString user99("User99");
int user00id = addTestContact(user00, phone00, RING_ACCOUNT);
int user99id = addTestContact(user99, phone99, RING_ACCOUNT);
CallModel model;
watcher.setModel(&model);
QDateTime when = QDateTime::currentDateTime();
addTestEvent(model, Event::CallEvent, Event::Inbound, RING_ACCOUNT, -1, "", false, false, when, phone00);
addTestEvent(model, Event::CallEvent, Event::Inbound, RING_ACCOUNT, -1, "", false, false, when.addSecs(10), phone99);
addTestEvent(model, Event::CallEvent, Event::Inbound, RING_ACCOUNT, -1, "", false, false, when.addSecs(20), phone00);
QVERIFY(watcher.waitForAdded(3));
model.setResolveContacts(true);
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
Event e;
e = model.event(model.index(0, 0));
QCOMPARE(e.contacts(), QList<ContactDetails>() << qMakePair(user00id, user00));
QCOMPARE(e.remoteUid(), phone00);
e = model.event(model.index(1, 0));
QCOMPARE(e.contacts(), QList<ContactDetails>() << qMakePair(user99id, user99));
QCOMPARE(e.remoteUid(), phone99);
e = model.event(model.index(2, 0));
QCOMPARE(e.contacts(), QList<ContactDetails>() << qMakePair(user00id, user00));
QCOMPARE(e.remoteUid(), phone00);
}
示例3: deleteAllCalls
void CallModelTest::deleteAllCalls()
{
CallModel model;
watcher.setModel(&model);
model.setQueryMode(EventModel::SyncQuery);
QDateTime when = QDateTime::currentDateTime();
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs( 54 ), REMOTEUID1 );
QVERIFY(watcher.waitForAdded());
QVERIFY(model.getEvents());
QVERIFY(model.rowCount() > 0);
QSignalSpy eventsCommitted(&model, SIGNAL(eventsCommitted(const QList<CommHistory::Event>&, bool)));
QVERIFY(model.deleteAll());
waitSignal(eventsCommitted);
QCOMPARE(model.rowCount(), 0);
QVERIFY(model.getEvents());
QCOMPARE(model.rowCount(), 0);
}
示例4: addEvents
static void addEvents(int from, int to)
{
EventModel eventsModel;
watcher.setModel(&eventsModel);
if (to >= 1 && from <= 1) {
QTest::qWait(1000);
addTestEvent(eventsModel, Event::CallEvent, Event::Inbound, phoneAccount, -1, "", false, false, QDateTime::currentDateTime(), alicePhone1);
}
if (to >= 2 && from <= 2) {
QTest::qWait(1000);
addTestEvent(eventsModel, Event::CallEvent, Event::Outbound, phoneAccount, -1, "", false, false, QDateTime::currentDateTime(), bobPhone);
}
if (to >= 3 && from <= 3) {
QTest::qWait(1000);
addTestEvent(eventsModel, Event::IMEvent, Event::Inbound, charlieIm1.first, group1.id(), "", false, false, QDateTime::currentDateTime(), charlieIm1.second);
}
if (to >= 4 && from <= 4) {
QTest::qWait(1000);
addTestEvent(eventsModel, Event::SMSEvent, Event::Outbound, phoneAccount, group1.id(), "", false, false, QDateTime::currentDateTime(), alicePhone2);
}
if (to >= 5 && from <= 5) {
QTest::qWait(1000);
addTestEvent(eventsModel, Event::CallEvent, Event::Inbound, phoneAccount, -1, "", false, false, QDateTime::currentDateTime(), bobPhone);
}
if (to >= 6 && from <= 6) {
QTest::qWait(1000);
addTestEvent(eventsModel, Event::IMEvent, Event::Outbound, charlieIm2.first, group1.id(), "", false, false, QDateTime::currentDateTime(), charlieIm2.second);
}
if (to >= 7 && from <= 7) {
QTest::qWait(1000);
addTestEvent(eventsModel, Event::IMEvent, Event::Outbound, bobIm.first, group1.id(), "", false, false, QDateTime::currentDateTime(), bobIm.second);
}
int count = to - from + 1;
QVERIFY(watcher.waitForAdded(count, count));
}
示例5: testModifyEvent
void CallModelTest::testModifyEvent()
{
Event e1, e2, e3;
deleteAll();
CallModel model;
watcher.setModel(&model);
/*
* user1, received
* user1, dialed
* user2, missed
* user1, received
* -> displayed as
* user1, received
* user2, missed
*/
QDateTime when = QDateTime::currentDateTime();
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when, REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(1), REMOTEUID2);
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(2), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs(3), REMOTEUID1);
QVERIFY(watcher.waitForAdded(6, 4)); // always grouped by contact -> +2
QVERIFY(model.setFilter(CallModel::SortByContact));
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.direction(), Event::Inbound);
e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID2);
QCOMPARE(e2.direction(), Event::Inbound);
/*
* upgrade latest user1 call to video:
* user1, received, video
* user1, dialed
* user2, missed
*/
e1.setIsVideoCall(true);
QVERIFY(model.modifyEvent(e1));
QVERIFY(watcher.waitForUpdated());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.direction(), Event::Inbound);
QCOMPARE(e1.isVideoCall(), true);
e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID1);
QCOMPARE(e2.direction(), Event::Outbound);
QCOMPARE(e2.isVideoCall(), false);
e3 = model.event(model.index(2, 0));
QCOMPARE(e3.remoteUid(), REMOTEUID2);
QCOMPARE(e3.direction(), Event::Inbound);
QCOMPARE(e3.isVideoCall(), false);
/*
* downgrade back to audio:
* user1, received
* user2, missed
*/
e1.setIsVideoCall(false);
QVERIFY(model.modifyEvent(e1));
QVERIFY(watcher.waitForUpdated());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.direction(), Event::Inbound);
e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID2);
QCOMPARE(e2.direction(), Event::Inbound);
}
示例6: testSIPAddress
void CallModelTest::testSIPAddress()
{
QSKIP("Contact matching is not yet supported with SQLite");
deleteAll();
CallModel model;
model.setQueryMode(EventModel::SyncQuery);
watcher.setModel(&model);
QString account("/org/freedesktop/Telepathy/Account/ring/tel/ring");
QString contactName("Donkey Kong");
QString phoneNumber("012345678");
QString sipAddress("sips:[email protected]");
QString contactName2("Mario");
QString sipAddress2("sips:[email protected]");
QDateTime when = QDateTime::currentDateTime();
int contactId = addTestContact(contactName, phoneNumber, account);
QVERIFY(contactId != -1);
int contactId2 = addTestContact(contactName2, sipAddress2, account);
QVERIFY(contactId2 != -1);
// normal phone call
addTestEvent(model, Event::CallEvent, Event::Outbound, account, -1, "", false, false, when, phoneNumber);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 1);
Event e = model.event(model.index(0, 0));
QCOMPARE(e.remoteUid(), phoneNumber);
// SIP call to same number, should group with first event
addTestEvent(model, Event::CallEvent, Event::Outbound, account, -1, "", false, false, when.addSecs(5), sipAddress);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 1);
e = model.event(model.index(0, 0));
QCOMPARE(e.remoteUid(), sipAddress);
// SIP call to non-numeric address
addTestEvent(model, Event::CallEvent, Event::Outbound, account, -1, "", false, false, when.addSecs(10), sipAddress2);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e = model.event(model.index(0, 0));
QCOMPARE(e.remoteUid(), sipAddress2);
// check contact resolving for call groups
QVERIFY(model.setFilter(CallModel::SortByContact));
QVERIFY(model.getEvents());
QCOMPARE(model.rowCount(), 2);
e = model.event(model.index(0, 0));
QCOMPARE(e.remoteUid(), sipAddress2);
QVERIFY(!e.contacts().isEmpty());
QCOMPARE(e.contacts().first().first, contactId2);
QCOMPARE(e.contacts().first().second, contactName2);
e = model.event(model.index(1, 0));
QCOMPARE(e.remoteUid(), sipAddress);
QVERIFY(!e.contacts().isEmpty());
QCOMPARE(e.contacts().first().first, contactId);
QCOMPARE(e.contacts().first().second, contactName);
// check contact resolving when sorting by time
QVERIFY(model.setFilter(CallModel::SortByTime));
QVERIFY(model.getEvents());
QCOMPARE(model.rowCount(), 2);
e = model.event(model.index(0, 0));
QCOMPARE(e.remoteUid(), sipAddress2);
QVERIFY(!e.contacts().isEmpty());
QCOMPARE(e.contacts().first().first, contactId2);
QCOMPARE(e.contacts().first().second, contactName2);
e = model.event(model.index(1, 0));
QCOMPARE(e.remoteUid(), sipAddress);
QVERIFY(!e.contacts().isEmpty());
QCOMPARE(e.contacts().first().first, contactId);
QCOMPARE(e.contacts().first().second, contactName);
deleteTestContact(contactId);
deleteTestContact(contactId2);
}
示例7: testSortByTimeUpdate
void CallModelTest::testSortByTimeUpdate()
{
deleteAll();
CallModel model;
watcher.setModel(&model);
/*
* user1, missed (2)
* (user1, dialed)
* user1, missed (1)
*/
QDateTime when = QDateTime::currentDateTime();
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when, REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(1), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(2), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(3), REMOTEUID1);
QVERIFY(watcher.waitForAdded(4));
QVERIFY(model.setFilter(CallModel::SortByTime, CallEvent::MissedCallType));
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 2);
Event e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.eventCount(), 2);
Event e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID1);
QVERIFY(e2.isMissedCall());
QVERIFY(e2.eventCount() <= 1);
// add received call, count for top item should reset
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs(4), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 1);
CallModel model2;
model2.setQueryMode(EventModel::SyncQuery);
QVERIFY(model2.getEvents(CallModel::SortByTime, CallEvent::MissedCallType));
QCOMPARE(model2.rowCount(), 2);
QVERIFY(model2.event(model2.index(0, 0)).eventCount() <= 1);
// add missed call, count should remain 1
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(5), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
int firstMissedId = e1.id();
QCOMPARE(e1.eventCount(), 1);
QCOMPARE(model2.event(model2.index(0, 0)).eventCount(), 1);
QVERIFY(model2.getEvents(CallModel::SortByTime, CallEvent::MissedCallType));
QCOMPARE(model2.rowCount(), 3);
QCOMPARE(model2.event(model2.index(0, 0)).eventCount(), 1);
// add another missed call, count should increase
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(6), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 2);
QCOMPARE(model2.event(model2.index(0, 0)).eventCount(), 2);
QVERIFY(model2.getEvents(CallModel::SortByTime, CallEvent::MissedCallType));
QCOMPARE(model2.rowCount(), 3);
QCOMPARE(model2.event(model.index(0, 0)).eventCount(), 2);
// mark latest missed call as read, the first should also be marked
Event e = model.event(model.index(0, 0));
e.setIsRead(true);
QVERIFY(model.modifyEvent(e));
QVERIFY(watcher.waitForUpdated(2));
QVERIFY(model.databaseIO().getEvent(firstMissedId, e));
QVERIFY(e.isRead());
}
示例8: testSortByContactUpdate
void CallModelTest::testSortByContactUpdate()
{
deleteAll();
CallModel model;
watcher.setModel(&model);
/*
* user1, missed (2)
* (user1, dialed)
* user1, missed (1)
*/
QDateTime when = QDateTime::currentDateTime();
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when, REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(1), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(2), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(3), REMOTEUID1);
QVERIFY(watcher.waitForAdded(4));
QVERIFY(model.setFilter(CallModel::SortByContact));
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
Event e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.eventCount(), 2);
// add received call
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs(4), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 1);
QCOMPARE(e1.direction(), Event::Inbound);
// add call to another contact
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(5), REMOTEUID2);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 1);
QCOMPARE(e1.direction(), Event::Outbound);
QCOMPARE(e1.remoteUid(), REMOTEUID2);
// missed call to first contact, should reorder
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(6), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
int firstMissedId = e1.id();
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.eventCount(), 1);
// another missed call, increase event count
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(7), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.eventCount(), 2);
// mark latest missed call as read, the first should also be marked
Event e = model.event(model.index(0, 0));
e.setIsRead(true);
QVERIFY(model.modifyEvent(e));
QVERIFY(watcher.waitForUpdated(7));
QVERIFY(model.databaseIO().getEvent(firstMissedId, e));
QVERIFY(e.isRead());
// add call to the other contact...
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(10), REMOTEUID2);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 2);
QCOMPARE(e1.direction(), Event::Outbound);
QCOMPARE(e1.remoteUid(), REMOTEUID2);
// ...and a missed call to the first -> move to top and increase event count
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(15), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.eventCount(), 3);
}
示例9: testGetEventsTimeTypeFilter
void CallModelTest::testGetEventsTimeTypeFilter()
{
QFETCH(bool, useThread);
deleteAll();
QThread modelThread;
//initTestCase ==> 3 dialled calls, 2 Received calls, 3 Missed Calls already added
CallModel model;
watcher.setModel(&model);
if (useThread) {
modelThread.start();
model.setBackgroundThread(&modelThread);
}
QDateTime when = QDateTime::currentDateTime();
//3 dialled
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when );
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(5) );
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(10) );
QVERIFY(watcher.waitForAdded(3));
//2 received
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when );
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs(5) );
QVERIFY(watcher.waitForAdded(2));
//3 missed
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when );
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(5) );
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(10) );
QVERIFY(watcher.waitForAdded(3));
QDateTime time = when;
//model.setQueryMode(EventModel::SyncQuery);
model.setTreeMode(false);
QVERIFY(model.setFilter(CallModel::SortByTime, CallEvent::DialedCallType, time));
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
int numEventsRet = model.rowCount();
QCOMPARE(numEventsRet, 3);
Event e1 = model.event(model.index(0,0));
Event e2 = model.event(model.index(1,0));
Event e3 = model.event(model.index(2,0));
QVERIFY(e1.isValid());
QVERIFY(e2.isValid());
QVERIFY(e3.isValid());
QVERIFY(e1.direction() == Event::Outbound);
QVERIFY(e2.direction() == Event::Outbound);
QVERIFY(e3.direction() == Event::Outbound);
QVERIFY(model.setFilter(CallModel::SortByTime, CallEvent::MissedCallType, time));
QVERIFY(watcher.waitForModelReady());
QVERIFY(model.rowCount() == 3);
QVERIFY(model.setFilter(CallModel::SortByTime, CallEvent::ReceivedCallType, time));
qDebug() << time;
QVERIFY(watcher.waitForModelReady());
for (int i = 0; i < model.rowCount(); i++) {
qDebug() << model.event(model.index(i, 0)).toString();
}
QVERIFY(model.rowCount() == 2);
/**
* testing to check for adding events with wrong filters
*/
time = when.addSecs(-60*5);
int numEventsGot = 0;
//adding one more received but 5 minutes before the set time filter
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, time );
QVERIFY(watcher.waitForAdded());
QVERIFY(model.rowCount() == 2); //event should not be added to model, so rowCount should remain same for received calls
//filter is set for received call, try to add missed and dialled calls with correct time filter
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when );
QVERIFY(watcher.waitForAdded());
numEventsGot = model.rowCount();
QVERIFY(numEventsGot == 2); //event should not be added to model, so rowCount should remain same which was for received calls
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when );
QVERIFY(watcher.waitForAdded());
numEventsGot = model.rowCount();
QVERIFY(numEventsGot == 2); //event should not be added to model, so rowCount should remain same which was for received calls
/**
** testing to check for getting events after he time when all events addition was complete
*/
//Trying to get events after 5 minutes after the first event was added
time = when.addSecs(60*5);
QVERIFY(model.setFilter(CallModel::SortByTime, CallEvent::ReceivedCallType, time));
QVERIFY(watcher.waitForModelReady());
QVERIFY(model.rowCount() == 0);
qDebug() << "wait thread";
modelThread.quit();
modelThread.wait(3000);
qDebug() << "done";
}
示例10: testAddEvent
void CallModelTest::testAddEvent()
{
CallModel model;
watcher.setModel(&model);
model.setQueryMode( EventModel::SyncQuery );
/* by contact:
* -----------
* user1, missed (2)
*/
testGetEvents( CallModel::SortByContact, 1, testCalls );
/* by time:
* --------
* user1, missed (2)
* user1, dialed (1)
* user1, received (2)
* user1, missed (1)
* user1, dialed (2)
*/
testGetEvents( CallModel::SortByTime, testCalls.count(), testCalls );
// add 1 dialed from user1
QDateTime when = QDateTime::currentDateTime();
addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs( 40 ), REMOTEUID1 );
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::DialedCallType, 1 ) );
QVERIFY(watcher.waitForAdded());
/* by contact:
* -----------
* user1, dialed (-1)
*/
testGetEvents( CallModel::SortByContact, 1, testCalls );
/* by time:
* --------
* user1, dialed (1)
* user1, missed (2)
* user1, dialed (1)
* user1, received (2)
* user1, missed (1)
* user1, dialed (2)
*/
testGetEvents( CallModel::SortByTime, testCalls.count(), testCalls );
// add 5 received from user1
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 45 ), REMOTEUID1 );
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 50 ), REMOTEUID1 );
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 55 ), REMOTEUID1 );
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 60 ), REMOTEUID1 );
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 65 ), REMOTEUID1 );
QVERIFY(watcher.waitForAdded(5));
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::ReceivedCallType, 5 ) );
/* by contact:
* -----------
* user1, received (-1)
*/
testGetEvents( CallModel::SortByContact, 1, testCalls );
/* by time:
* --------
* user1, received (5)
* user1, dialed (1)
* user1, missed (2)
* user1, dialed (1)
* user1, received (2)
* user1, missed (1)
* user1, dialed (2)
*/
testGetEvents( CallModel::SortByTime, testCalls.count(), testCalls );
// add 1 missed from user2
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs( 70 ), REMOTEUID2 );
testCalls.insert( 0, TestCallItem( REMOTEUID2, CallEvent::MissedCallType, 1 ) );
QVERIFY(watcher.waitForAdded());
/* by contact:
* -----------
* user2, missed (1)
* user1, received (0)
*/
testGetEvents( CallModel::SortByContact, 2, testCalls );
/* by time:
* --------
* user2, received (1)
* user1, received (5)
* user1, dialed (1)
* user1, missed (2)
* user1, dialed (1)
* user1, received (2)
* user1, missed (1)
* user1, dialed (2)
*/
testGetEvents( CallModel::SortByTime, testCalls.count(), testCalls );
// add 1 received from user1
addTestEvent( model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs( 75 ), REMOTEUID1 );
testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::ReceivedCallType, 1 ) );
QVERIFY(watcher.waitForAdded());
/* by contact: ***REORDERING
* -----------
//.........这里部分代码省略.........