当前位置: 首页>>代码示例>>C++>>正文


C++ ModelWatcher::waitForModelReady方法代码示例

本文整理汇总了C++中ModelWatcher::waitForModelReady方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelWatcher::waitForModelReady方法的具体用法?C++ ModelWatcher::waitForModelReady怎么用?C++ ModelWatcher::waitForModelReady使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelWatcher的用法示例。


在下文中一共展示了ModelWatcher::waitForModelReady方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: contacts

void ConversationModelTest::contacts()
{
    QFETCH(QString, localId);
    QFETCH(QString, remoteId);
    QFETCH(int, eventType);

    Group group;
    addTestGroup(group, localId, remoteId);

    ConversationModel model;
    Event::PropertySet p;
    p.insert(Event::ContactId);
    p.insert(Event::ContactName);
    model.setPropertyMask(p);

    model.enableContactChanges(false);
    watcher.setModel(&model);

    addTestEvent(model, (Event::EventType)eventType, Event::Inbound, localId,
                 group.id(), "text", false, false, QDateTime::currentDateTime(), remoteId);

    QVERIFY(model.getEvents(group.id()));
    QVERIFY(watcher.waitForModelReady());

    Event event;
    event = model.event(model.index(0, 0));
    QCOMPARE(event.contactId(), 0);

    QString noMatch = remoteId;
    noMatch += remoteId[1];

    int contactId1 = addTestContact("Really1Funny",
                   noMatch,
                   localId);

    QVERIFY(model.getEvents(group.id()));
    QVERIFY(watcher.waitForModelReady());

    event = model.event(model.index(0, 0));
    QCOMPARE(event.contactId(), 0);

    int contactId = addTestContact("ReallyUFunny", remoteId, localId);
    QTime timer;
    timer.start();
    while (timer.elapsed() < 1000)
        QCoreApplication::processEvents();
    QVERIFY(model.getEvents(group.id()));
    QVERIFY(watcher.waitForModelReady());

    event = model.event(model.index(0, 0));
    QCOMPARE(event.contactId(), contactId);
    QCOMPARE(event.contactName(), QString("ReallyUFunny"));

    deleteTestContact(contactId1);
    deleteTestContact(contactId);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:56,代码来源:conversationmodeltest.cpp

示例2: 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);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:52,代码来源:singleeventmodeltest.cpp

示例3: asyncMode

void ConversationModelTest::asyncMode()
{
    ConversationModel model;
    model.enableContactChanges(false);
    watcher.setModel(&model);
    QVERIFY(model.getEvents(group1.id()));
    QVERIFY(watcher.waitForModelReady());
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:8,代码来源:conversationmodeltest.cpp

示例4: reset

void ConversationModelTest::reset() {
    ConversationModel conv;
    conv.enableContactChanges(false);
    watcher.setModel(&conv);

    QVERIFY(conv.getEvents(group1.id()));

    QVERIFY(watcher.waitForModelReady());

    QVERIFY(conv.rowCount() >= 5 );

    QSignalSpy modelReset(&conv, SIGNAL(modelReset()));
    GroupModel groups;
    groups.deleteGroups(QList<int>() << group1.id());
    if (modelReset.isEmpty())
       QVERIFY(waitSignal(modelReset));
    QCOMPARE(conv.rowCount(), 0);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:18,代码来源:conversationmodeltest.cpp

示例5: 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);
}
开发者ID:sledges,项目名称:libcommhistory,代码行数:44,代码来源:callmodeltest.cpp

示例6: 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));
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:36,代码来源:singleeventmodeltest.cpp

示例7: 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);
}
开发者ID:jpetrell,项目名称:libcommhistory,代码行数:75,代码来源:callmodeltest.cpp

示例8: 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());
}
开发者ID:jpetrell,项目名称:libcommhistory,代码行数:76,代码来源:callmodeltest.cpp

示例9: 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);
}
开发者ID:jpetrell,项目名称:libcommhistory,代码行数:90,代码来源:callmodeltest.cpp

示例10: 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";
}
开发者ID:jpetrell,项目名称:libcommhistory,代码行数:97,代码来源:callmodeltest.cpp

示例11: testDeleteEvent

void CallModelTest::testDeleteEvent()
{
    CallModel model;
    watcher.setModel(&model);

    // force change of sorting to SortByContact
    QVERIFY( model.setFilter( CallModel::SortByContact ) );
    QVERIFY( model.getEvents() );
    QVERIFY(watcher.waitForModelReady());

    /* by contact:
     * -----------
     * "", received (0)
     * user2, received (0)
     * user1, received (0)
     */
    // delete first event from hidden number
    Event e = model.event( model.index( 0, 0 ) );
    QVERIFY( e.isValid() );
    QCOMPARE( e.type(), Event::CallEvent );
    qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
    QCOMPARE( e.direction(), Event::Inbound );
    QCOMPARE( e.isMissedCall(), false );
    QCOMPARE( e.remoteUid(), QLatin1String("<hidden>") );
    // delete it
    QVERIFY( model.deleteEvent( e.id() ) );
    QVERIFY( watcher.waitForDeleted() );
    // correct test helper lists to match current situation
    QMutableListIterator<TestCallItem> i(testCalls);
    while (i.hasNext()) {
        i.next();
        if (i.value().remoteUid == QLatin1String("<hidden>"))
            i.remove();
    }
    // test if model contains what we want it does
    testGetEvents( CallModel::SortByContact, 2, testCalls );

    /* by contact:
     * -----------
     * user2, received (0)
     * user1, received (0)
     */
    // delete first group from user2
    e = model.event( model.index( 0, 0 ) );
    QVERIFY( e.isValid() );
    QCOMPARE( e.type(), Event::CallEvent );
    qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
    QCOMPARE( e.direction(), Event::Inbound );
    QCOMPARE( e.isMissedCall(), false );
    QCOMPARE( e.remoteUid(), REMOTEUID2 );
    // delete it
    QVERIFY( model.deleteEvent( e.id() ) );
    QVERIFY( watcher.waitForDeleted(2) );
    // correct test helper lists to match current situation
    i = QMutableListIterator<TestCallItem>(testCalls);
    while (i.hasNext()) {
        i.next();
        if (i.value().remoteUid == REMOTEUID2)
            i.remove();
    }
    // test if model contains what we want it does
    testGetEvents( CallModel::SortByContact, 1, testCalls );

    // force change of sorting to SortByTime
    QVERIFY( model.setFilter( CallModel::SortByTime ) );
    QVERIFY(watcher.waitForModelReady());

    /* by time:
     * --------
     * user1, received (6)***
     * user1, dialed   (1)
     * user1, missed   (2)
     * user1, dialed   (1)
     * user1, received (2)
     * user1, missed   (1)
     * user1, dialed   (2)
     *
     *     ||
     *     \/
     *
     * user1, dialed   (1)
     * user1, missed   (2)
     * user1, dialed   (1)
     * user1, received (2)
     * user1, missed   (1)
     * user1, dialed   (2)
     */
    // take the event
    e = model.event( model.index( 0, 0 ) );
    QVERIFY( e.isValid() );
    QCOMPARE( e.type(), Event::CallEvent );
    qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
    QCOMPARE( e.direction(), Event::Inbound );
    QCOMPARE( e.isMissedCall(), false );
    // delete it
    QVERIFY( model.deleteEvent( e.id() ) );
    QVERIFY( watcher.waitForDeleted(6) );
    // correct test helper lists to match current situation
    foreach (TestCallItem item, testCalls) {
        qDebug() << item.remoteUid << item.callType << item.eventCount;
//.........这里部分代码省略.........
开发者ID:jpetrell,项目名称:libcommhistory,代码行数:101,代码来源:callmodeltest.cpp

示例12: 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);

//.........这里部分代码省略.........
开发者ID:adenexter,项目名称:libcommhistory,代码行数:101,代码来源:singleeventmodeltest.cpp

示例13: 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);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:73,代码来源:singleeventmodeltest.cpp

示例14: 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);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:90,代码来源:conversationmodeltest.cpp


注:本文中的ModelWatcher::waitForModelReady方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。