~ci-train-bot/history-service/history-service-ubuntu-zesty-2629

« back to all changes in this revision

Viewing changes to tests/libhistoryservice/ContactMatcherTest.cpp

Move the classes from historyprivate static library to libhistoryservice itself and just keep their header files private.
Approved by: Tiago Salem Herrmann, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
{
60
60
    initialize();
61
61
    mContactManager = new QContactManager("memory");
62
 
    ContactMatcher::instance(mContactManager);
 
62
    History::ContactMatcher::instance(mContactManager);
63
63
 
64
64
    // create two contacts to test
65
65
    mPhoneContact = createContact("Phone", "Contact", QStringList() << "123456789" << "7654321");
97
97
    QFETCH(QString, contactId);
98
98
    QFETCH(bool, phoneNumberCompare);
99
99
 
100
 
    QSignalSpy contactInfoSpy(ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
101
 
    QVariantMap info = ContactMatcher::instance()->contactInfo(accountId, identifier);
 
100
    QSignalSpy contactInfoSpy(History::ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
 
101
    QVariantMap info = History::ContactMatcher::instance()->contactInfo(accountId, identifier);
102
102
    if (phoneNumberCompare) {
103
 
        QVERIFY(PhoneUtils::comparePhoneNumbers(info[History::FieldIdentifier].toString(), identifier));
 
103
        QVERIFY(History::PhoneUtils::comparePhoneNumbers(info[History::FieldIdentifier].toString(), identifier));
104
104
    } else {
105
105
        QCOMPARE(info[History::FieldIdentifier].toString(), identifier);
106
106
    }
111
111
    info = contactInfoSpy.first()[2].toMap();
112
112
    QCOMPARE(info[History::FieldContactId].toString(), contactId);
113
113
    if (phoneNumberCompare) {
114
 
        QVERIFY(PhoneUtils::comparePhoneNumbers(info[History::FieldIdentifier].toString(), identifier));
 
114
        QVERIFY(History::PhoneUtils::comparePhoneNumbers(info[History::FieldIdentifier].toString(), identifier));
115
115
    } else {
116
116
        QCOMPARE(info[History::FieldIdentifier].toString(), identifier);
117
117
    }
119
119
 
120
120
void ContactMatcherTest::testContactAdded()
121
121
{
122
 
    QSignalSpy contactInfoSpy(ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
 
122
    QSignalSpy contactInfoSpy(History::ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
123
123
    QString identifier("5555555");
124
124
    QString accountId("mock/ofono/account0");
125
 
    QVariantMap info = ContactMatcher::instance()->contactInfo(accountId, identifier);
 
125
    QVariantMap info = History::ContactMatcher::instance()->contactInfo(accountId, identifier);
126
126
    QCOMPARE(info[History::FieldIdentifier].toString(), identifier);
127
127
    QVERIFY(!info.contains(History::FieldContactId));
128
128
 
136
136
 
137
137
void ContactMatcherTest::testContactRemoved()
138
138
{
139
 
    QSignalSpy contactInfoSpy(ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
 
139
    QSignalSpy contactInfoSpy(History::ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
140
140
    QString identifier("6666666");
141
141
    QString accountId("mock/ofono/account0");
142
 
    QVariantMap info = ContactMatcher::instance()->contactInfo(accountId, identifier);
 
142
    QVariantMap info = History::ContactMatcher::instance()->contactInfo(accountId, identifier);
143
143
    QCOMPARE(info[History::FieldIdentifier].toString(), identifier);
144
144
 
145
145
    // now add a contact that matches this item
164
164
    QContact contact = createContact("Synchronous", "Contact", QStringList() << identifier);
165
165
 
166
166
    // now that the contact info is filled, remove the contact
167
 
    QVariantMap info = ContactMatcher::instance()->contactInfo(accountId, identifier, true);
 
167
    QVariantMap info = History::ContactMatcher::instance()->contactInfo(accountId, identifier, true);
168
168
    QCOMPARE(info[History::FieldIdentifier].toString(), identifier);
169
169
    QCOMPARE(info[History::FieldAccountId].toString(), accountId);
170
170
    QVERIFY(!info[History::FieldContactId].toString().isEmpty());
178
178
    QString identifier("88888888");
179
179
    QString accountId("mock/ofono/account0");
180
180
 
181
 
    ContactMatcher::instance()->watchIdentifier(accountId, identifier);
 
181
    History::ContactMatcher::instance()->watchIdentifier(accountId, identifier);
182
182
 
183
183
    // now add a contact and make sure we get the contactInfoChanged signal
184
 
    QSignalSpy contactInfoSpy(ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
 
184
    QSignalSpy contactInfoSpy(History::ContactMatcher::instance(), SIGNAL(contactInfoChanged(QString,QString,QVariantMap)));
185
185
    QContact contact = createContact("Contact", "Watched", QStringList() << identifier);
186
186
    QTRY_COMPARE(contactInfoSpy.count(), 1);
187
187
    QCOMPARE(contactInfoSpy.first()[0].toString(), accountId);