433 QVERIFY( !state.enterL() ); |
433 QVERIFY( !state.enterL() ); |
434 QVERIFY( mContactCache.count() == 0 ); |
434 QVERIFY( mContactCache.count() == 0 ); |
435 QVERIFY( !logsEvent->contactLocalId() ); |
435 QVERIFY( !logsEvent->contactLocalId() ); |
436 QVERIFY(!logsEvent->contactMatched()); |
436 QVERIFY(!logsEvent->contactMatched()); |
437 |
437 |
|
438 |
438 // Some events, nothing yet in cache, match from phonebook found (international format) |
439 // Some events, nothing yet in cache, match from phonebook found (international format) |
|
440 // Match is not used for event which has already remoteparty name |
439 QtContactsStubsHelper::setContactNames("first", "last"); |
441 QtContactsStubsHelper::setContactNames("first", "last"); |
440 logsEvent->setNumber( "+3581112222" ); |
442 logsEvent->setNumber( "+3581112222" ); |
|
443 logsEvent2->setNumber( "+3581112222" ); |
441 QVERIFY( !state.enterL() ); |
444 QVERIFY( !state.enterL() ); |
442 QVERIFY( mContactCache.count() == 1 ); |
445 QVERIFY( mContactCache.count() == 1 ); |
443 QVERIFY( logsEvent->contactLocalId() == contactId ); |
446 QVERIFY( logsEvent->contactLocalId() == contactId ); |
444 QVERIFY(logsEvent->contactMatched()); |
447 QVERIFY(logsEvent->contactMatched()); |
445 QVERIFY(logsEvent->remoteParty().length() > 0); |
448 QCOMPARE(logsEvent->remoteParty(), QString("first last") ); |
|
449 QVERIFY(!logsEvent2->contactMatched()); |
|
450 QCOMPARE(logsEvent2->remoteParty(), QString("remote2") ); |
446 |
451 |
447 // Some events, nothing yet in cache, match from phonebook found (local format) |
452 // Some events, nothing yet in cache, match from phonebook found (local format) |
448 mContactCache.clear(); |
453 mContactCache.clear(); |
449 logsEvent->setRemoteParty( "" ); |
454 logsEvent->setRemoteParty( "" ); |
450 logsEvent->setNumber( "11112222" ); |
455 logsEvent->setNumber( "11112222" ); |
451 logsEvent->setLogsEventData(NULL); |
456 logsEvent->setLogsEventData(NULL); |
452 QVERIFY( !state.enterL() ); |
457 QVERIFY( !state.enterL() ); |
453 QVERIFY( mContactCache.count() == 1 ); |
458 QVERIFY( mContactCache.count() == 1 ); |
454 QVERIFY( logsEvent->contactLocalId() == contactId ); |
459 QVERIFY( logsEvent->contactLocalId() == contactId ); |
455 QVERIFY(logsEvent->contactMatched()); |
460 QVERIFY(logsEvent->contactMatched()); |
456 QVERIFY(logsEvent->remoteParty().length() > 0); |
461 QCOMPARE(logsEvent->remoteParty(), QString("first last") ); |
457 |
462 |
458 // Some events, matching info found from cache |
463 // Some events, matching info found from cache |
459 logsEvent->setLogsEventData(NULL); |
464 logsEvent->setLogsEventData(NULL); |
460 logsEvent->setRemoteParty( "" ); |
465 logsEvent->setRemoteParty( "" ); |
461 QVERIFY( !logsEvent->contactLocalId() ); |
466 QVERIFY( !logsEvent->contactLocalId() ); |
463 QVERIFY( mContactCache.count() == 1 ); |
468 QVERIFY( mContactCache.count() == 1 ); |
464 QVERIFY( logsEvent->remoteParty().length() > 0 ); |
469 QVERIFY( logsEvent->remoteParty().length() > 0 ); |
465 QVERIFY( logsEvent->contactLocalId() == contactId ); |
470 QVERIFY( logsEvent->contactLocalId() == contactId ); |
466 |
471 |
467 QtContactsStubsHelper::setContactNames("updated", "last"); |
472 QtContactsStubsHelper::setContactNames("updated", "last"); |
468 QVERIFY( logsEvent->remoteParty() == "first last" ); |
473 QCOMPARE(logsEvent->remoteParty(), QString("first last") ); |
469 mContactCache.clear(); |
474 mContactCache.clear(); |
470 logsEvent->setContactMatched( false ); |
475 logsEvent->setContactMatched( false ); |
471 logsEvent->setRemoteParty(""); |
476 logsEvent->setRemoteParty(""); |
472 QVERIFY(!logsEvent->contactMatched()); |
477 QVERIFY(!logsEvent->contactMatched()); |
473 QVERIFY( mContactCache.count() == 0 ); |
478 QVERIFY( mContactCache.count() == 0 ); |
481 //matching info not found in cache |
486 //matching info not found in cache |
482 QtContactsStubsHelper::reset(); |
487 QtContactsStubsHelper::reset(); |
483 mContactCache.clear(); |
488 mContactCache.clear(); |
484 logsEvent->setContactMatched( false ); |
489 logsEvent->setContactMatched( false ); |
485 logsEvent->setRemoteParty(""); |
490 logsEvent->setRemoteParty(""); |
|
491 logsEvent->setNumber( "5555" ); |
486 QVERIFY( mContactCache.count() == 0 ); |
492 QVERIFY( mContactCache.count() == 0 ); |
487 QVERIFY( logsEvent->remoteParty().length() == 0 ); |
493 QVERIFY( logsEvent->remoteParty().length() == 0 ); |
488 QVERIFY( !state.enterL() ); |
494 QVERIFY( !state.enterL() ); |
489 QVERIFY( mContactCache.count() == 0 ); |
495 QVERIFY( mContactCache.count() == 0 ); |
490 QVERIFY( logsEvent->remoteParty().length() == 0 ); |
496 QVERIFY( logsEvent->remoteParty().length() == 0 ); |
491 QVERIFY(!logsEvent->contactMatched()); |
497 QVERIFY(!logsEvent->contactMatched()); |
|
498 |
|
499 // Check that optimization for avoiding multiple searches |
|
500 // per one number works |
|
501 QtContactsStubsHelper::reset(); |
|
502 mContactCache.clear(); |
|
503 LogsEvent* logsEvent3 = new LogsEvent; |
|
504 logsEvent3->setNumber( "5555" ); |
|
505 logsEvent3->setIsInView(true); |
|
506 mEvents.append( logsEvent3 ); |
|
507 QCOMPARE( logsEvent->number(), logsEvent3->number() ); |
|
508 QVERIFY( !state.enterL() ); |
|
509 QVERIFY( mContactCache.count() == 0 ); |
|
510 QVERIFY( logsEvent->remoteParty().length() == 0 ); |
|
511 QVERIFY( logsEvent3->remoteParty().length() == 0 ); |
|
512 QVERIFY(!logsEvent->contactMatched()); |
|
513 QVERIFY(!logsEvent3->contactMatched()); |
|
514 QCOMPARE( QtContactsStubsHelper::contactIdsMethodCallCount(), 1 ); |
492 |
515 |
493 } |
516 } |
494 |
517 |
495 void UT_LogsReaderStates::testStateFillDetails2() |
518 void UT_LogsReaderStates::testStateFillDetails2() |
496 { |
519 { |