~tiagosh/telephony-service/delete_player_instance_on_incoming_call

« back to all changes in this revision

Viewing changes to tests/Ubuntu.Telephony/ContactWatcherTest.cpp

Check contact results on the client side. Phone comparison in the server side is not reliable. Fixes: #1476833
Approved by: PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    void testLateSearch();
47
47
    void testAddressableFields();
48
48
    void testExtendedFieldMatch();
 
49
    void testSimilarPhoneNumbers();
49
50
 
50
51
private:
51
52
    QContact createContact(const QString &firstName,
474
475
    QCOMPARE(watcher.contactId(), contact.id().toString());
475
476
}
476
477
 
 
478
void ContactWatcherTest::testSimilarPhoneNumbers()
 
479
{
 
480
    QString contactIdentifierA("+352 661 123456");
 
481
    QString contactIdentifierB("+352 691 123456");
 
482
    QContact contactA = createContact("FirstName",
 
483
                                     "LastName",
 
484
                                     "file://some_file",
 
485
                                     QStringList() << contactIdentifierA,
 
486
                                     QList<int>() << 0 << 1 << 2,
 
487
                                     QList<int>() << 3 << 4 << 5);
 
488
    QContact contactB = createContact("FirstName",
 
489
                                     "LastName",
 
490
                                     "file://some_file",
 
491
                                     QStringList() << contactIdentifierB,
 
492
                                     QList<int>() << 0 << 1 << 2,
 
493
                                     QList<int>() << 3 << 4 << 5);
 
494
    ContactWatcher watcherA;
 
495
    QSignalSpy contactIdSpyA(&watcherA, SIGNAL(contactIdChanged()));
 
496
 
 
497
    // try to match contact A
 
498
    watcherA.setIdentifier(contactIdentifierA);
 
499
 
 
500
    // mark as complete
 
501
    watcherA.componentComplete();
 
502
 
 
503
    // signal will be fired now
 
504
    QTRY_COMPARE(contactIdSpyA.count(), 1);
 
505
 
 
506
    QCOMPARE(watcherA.contactId(), contactA.id().toString());
 
507
 
 
508
    ContactWatcher watcherB;
 
509
    QSignalSpy contactIdSpyB(&watcherB, SIGNAL(contactIdChanged()));
 
510
 
 
511
    // mark as complete
 
512
    watcherB.componentComplete();
 
513
 
 
514
    // try to match contact B
 
515
    watcherB.setIdentifier(contactIdentifierB);
 
516
 
 
517
    // signal will be fired now
 
518
    QTRY_COMPARE(contactIdSpyB.count(), 1);
 
519
 
 
520
    QCOMPARE(watcherB.contactId(), contactB.id().toString());
 
521
}
 
522
 
477
523
QContact ContactWatcherTest::createContact(const QString &firstName,
478
524
                                           const QString &lastName,
479
525
                                           const QString &avatarUrl,