Esempio n. 1
0
LOCAL_C void TestFilteringL()
{
    _LIT(KProgressIndicator,".");
    test.Printf(KProgressIndicator);

    CCntFilter* filter = CCntFilter::NewL();
    CleanupStack::PushL(filter);

    filter->SetContactFilterTypeCard(ETrue);
    TTime time;
    time.UniversalTime();
    time-=TTimeIntervalMinutes(20); // changes in the last 20 mins
    filter->SetFilterDateTime(time);
    filter->SetIncludeNewContacts(ETrue);
    CntTest->Db()->FilterDatabaseL(*filter);
    test(filter->iIds->Count()==KTotalNumRecords);

// modified contact
    User::After(4000000);	// Let time pass to distinguish between mod  / new
    // this may still fail if the device is running too slow (e.g. under a heavy load)

    filter->Reset();
    time.UniversalTime();
    filter->SetFilterDateTime(time);
    filter->SetIncludeModifiedContacts(ETrue);
    CntTest->Db()->FilterDatabaseL(*filter);
    test(filter->iIds->Count()==0);

    CContactItem* contact = CntTest->Db()->OpenContactLX(5);
    CleanupStack::PushL(contact);
    contact->IncAccessCount();
    CntTest->Db()->CommitContactL(*contact);
    CleanupStack::PopAndDestroy(contact);
    CleanupStack::Pop(); // contact.Close()

    CntTest->Db()->FilterDatabaseL(*filter);
    test(filter->iIds->Count()==1);

// deleted contact
    filter->Reset();
    filter->SetFilterDateTime(time); // same time as for modified
    filter->SetIncludeDeletedContacts(ETrue);
    CntTest->Db()->FilterDatabaseL(*filter);
    test(filter->iIds->Count()==0);

    CntTest->Db()->DeleteContactL(5);
    CntTest->Db()->FilterDatabaseL(*filter);
    TInt deletedContactCount = filter->iIds->Count();
    test(deletedContactCount ==1);

#ifdef _DEBUG
    CContactIdArray* deletedCntArray = CntTest->Db()->DeletedContactsLC();
    test(deletedCntArray->Count()==deletedContactCount);
    CleanupStack::PopAndDestroy(deletedCntArray );
#endif

    CleanupStack::PopAndDestroy(filter);
}
Esempio n. 2
0
// Construction tests
// NewL methods are called by NewLC variants so there's no tests for that
//
LOCAL_C void TestFilterConstructionL()
{
    CCntFilter* filter = CCntFilter::NewLC();
    TTime time;
    time.UniversalTime();
    filter->SetFilterDateTime(time);

    CCntFilter* clone = CCntFilter::NewLC(filter);
    test(clone->GetFilterDateTime()==time);

    CleanupStack::PopAndDestroy(2); //filter,clone
}
Esempio n. 3
0
LOCAL_C void SimpleFilterTestL()
{
    CCntFilter* filter = CCntFilter::NewL();
    CleanupStack::PushL(filter);
    filter->SetContactFilterTypeCard(ETrue);
    TTime time;
    time.UniversalTime();
    time-=TTimeIntervalMinutes(20); // changes in the last 20 mins
    filter->SetFilterDateTime(time);
    filter->SetIncludeNewContacts(ETrue);
    CntTest->Db()->FilterDatabaseL(*filter);
    test(filter->iIds->Count()==KTotalNumRecords);
    CleanupStack::PopAndDestroy(filter);
}
CCntFilter* CPackagerCntFactory::doCreateDefaultCCntFilterL() const
/** Implementation method for constructing a new default CCntFilter object. 

@return a Pointer to the CCntFilter object. */
	{
	CCntFilter* theFilter = CCntFilter::NewLC();
	theFilter->SetContactFilterTypeCard(ETrue);
	TTime time;
	time.UniversalTime();
	time-=TTimeIntervalMinutes(KInterval); // changes in the last KInterval mins
	theFilter->SetFilterDateTime(time);
	theFilter->SetIncludeNewContacts(ETrue);
	theFilter->SetContactFilterTypeALL(ETrue);
	theFilter->iIds = doCreateDefaultCContactIdArrayL();
	CleanupStack::Pop(theFilter);
	return theFilter;
	}	
Esempio n. 5
0
// SetInclude* are exclusive
// SetContactFilterType* is cumulative
//
LOCAL_C void CheckFilterSettingsL(TBool aSetting)
{
    CCntFilter* filter = CCntFilter::NewLC();

    filter->Reset();
    filter->SetIncludeModifiedContacts(aSetting);
    if (aSetting)
    {
        test(filter->IncludeModifiedContacts());
        test(!filter->IncludeNewContacts());
        test(!filter->IncludeDeletedContacts());
    }

    filter->SetIncludeNewContacts(aSetting);
    if (aSetting)
    {
        test(filter->IncludeNewContacts());
        test(!filter->IncludeModifiedContacts());
        test(!filter->IncludeDeletedContacts());
    }


    filter->SetIncludeDeletedContacts(aSetting);
    if (aSetting)
    {
        test(filter->IncludeDeletedContacts());
        test(!filter->IncludeModifiedContacts());
        test(!filter->IncludeNewContacts());
    }

    filter->SetContactFilterTypeCard(aSetting);
    filter->SetContactFilterTypeGroup(aSetting);
    filter->SetContactFilterTypeTemplate(aSetting);
    filter->SetContactFilterTypeOwnCard(aSetting);
    if (aSetting)
    {
        test(filter->ContactFilterTypeGroup());
        test(filter->ContactFilterTypeCard());
        test(filter->ContactFilterTypeTemplate());
        test(filter->ContactFilterTypeOwnCard());
    }
    else
    {
        test(!filter->ContactFilterTypeGroup());
        test(!filter->ContactFilterTypeCard());
        test(!filter->ContactFilterTypeTemplate());
        test(!filter->ContactFilterTypeOwnCard());
    }

    filter->SetContactFilterTypeALL(aSetting);
    if (aSetting)
    {
        test(filter->ContactFilterTypeALL());
        test(filter->ContactFilterTypeGroup());
        test(filter->ContactFilterTypeCard());
        test(filter->ContactFilterTypeTemplate());
        test(filter->ContactFilterTypeOwnCard());
    }

    TTime time;
    time.UniversalTime();
    filter->SetFilterDateTime(time);
    test(filter->GetFilterDateTime()==time);

    CleanupStack::PopAndDestroy(filter);
}