~ci-train-bot/history-service/history-service-ubuntu-yakkety-landing-052

« back to all changes in this revision

Viewing changes to tests/libhistoryservice/VoiceEventTest.cpp

Request contact information for all known participants on history-daemon initialization, and use this cached information on the models.
Approved by: Tiago Salem Herrmann, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    void testFromNullProperties();
35
35
    void testProperties_data();
36
36
    void testProperties();
 
37
 
 
38
private:
 
39
    History::Participants participantsFromIdentifiers(const QString &accountId, const QStringList &identifiers);
37
40
};
38
41
 
39
42
void VoiceEventTest::testCreateNewEvent_data()
76
79
    QFETCH(QString, remoteParticipant);
77
80
    QFETCH(QStringList, participants);
78
81
    History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent,
79
 
                              missed, duration, remoteParticipant, participants);
 
82
                              missed, duration, remoteParticipant, participantsFromIdentifiers(accountId, participants));
80
83
 
81
84
    // check that the values are properly set
82
85
    QCOMPARE(event.accountId(), accountId);
88
91
    QCOMPARE(event.missed(), missed);
89
92
    QCOMPARE(event.duration(), duration);
90
93
    QCOMPARE(event.remoteParticipant(), remoteParticipant);
91
 
    QCOMPARE(event.participants(), participants);
 
94
    QCOMPARE(event.participants().identifiers(), participants);
92
95
}
93
96
 
94
97
void VoiceEventTest::testCastToEventAndBack()
95
98
{
96
 
    History::VoiceEvent voiceEvent("oneAccountId", "oneThreadId", "oneEventId", "oneSender", QDateTime::currentDateTime(),
97
 
                                   true, true, QTime(1,2,3), "remoteParticipant", QStringList() << "oneParticipant");
 
99
    QString accountId("oneAccountId");
 
100
    History::VoiceEvent voiceEvent(accountId, "oneThreadId", "oneEventId", "oneSender", QDateTime::currentDateTime(),
 
101
                                   true, true, QTime(1,2,3), "remoteParticipant",
 
102
                                   participantsFromIdentifiers(accountId, QStringList() << "oneParticipant"));
98
103
 
99
104
    // test the copy constructor
100
105
    History::Event historyEvent(voiceEvent);
155
160
    properties[History::FieldNewEvent] = newEvent;
156
161
    properties[History::FieldMissed] = missed;
157
162
    properties[History::FieldDuration] = QTime(0,0,0,0).secsTo(duration);
158
 
    properties[History::FieldParticipants] = participants;
 
163
    properties[History::FieldParticipants] = participantsFromIdentifiers(accountId, participants).toVariantList();
159
164
 
160
165
    History::VoiceEvent voiceEvent = History::VoiceEvent::fromProperties(properties);
161
166
    QCOMPARE(voiceEvent.accountId(), accountId);
166
171
    QCOMPARE(voiceEvent.newEvent(), newEvent);
167
172
    QCOMPARE(voiceEvent.missed(), missed);
168
173
    QCOMPARE(voiceEvent.duration(), duration);
169
 
    QCOMPARE(voiceEvent.participants(), participants);
 
174
    QCOMPARE(voiceEvent.participants().identifiers(), participants);
170
175
}
171
176
 
172
177
void VoiceEventTest::testFromNullProperties()
217
222
    QFETCH(QString, remoteParticipant);
218
223
    QFETCH(QStringList, participants);
219
224
    History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent,
220
 
                              missed, duration, remoteParticipant, participants);
 
225
                              missed, duration, remoteParticipant, participantsFromIdentifiers(accountId, participants));
221
226
 
222
227
    // check that the values are properly set
223
228
    QVariantMap properties = event.properties();
230
235
    QCOMPARE(properties[History::FieldMissed].toBool(), missed);
231
236
    QCOMPARE(QTime(0,0).addSecs(properties[History::FieldDuration].toInt()), duration);
232
237
    QCOMPARE(properties[History::FieldRemoteParticipant].toString(), remoteParticipant);
233
 
    QCOMPARE(properties[History::FieldParticipants].toStringList(), participants);
 
238
    QCOMPARE(History::Participants::fromVariant(properties[History::FieldParticipants]).identifiers(), participants);
 
239
}
 
240
 
 
241
History::Participants VoiceEventTest::participantsFromIdentifiers(const QString &accountId, const QStringList &identifiers)
 
242
{
 
243
    History::Participants participants;
 
244
    Q_FOREACH(const QString &identifier, identifiers) {
 
245
        participants << History::Participant(accountId, identifier);
 
246
    }
 
247
    return participants;
234
248
}
235
249
 
236
250
QTEST_MAIN(VoiceEventTest)