Esempio n. 1
0
LOCAL_C void CreateEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry, TInt aError, CEntryObserver& aObserver)
{
    CTestActive* active = new (ELeave) CTestActive;
    CleanupStack::PushL(active);
    active->StartL();
    aObserver.Start();
    CMsvOperation*  opert = aClientEntry.CreateL(aNewEntry, active->iStatus);
    CActiveScheduler::Start(); // operation complete
    CActiveScheduler::Start(); // cEntry changed
    test(opert->iStatus.Int()==KErrNone);
    test(opert->Mtm()==KUidMsvLocalServiceMtm);
    test(opert->Service()==KMsvLocalServiceIndexEntryId);
    TMsvLocalOperationProgress details;
    TPckgC<TMsvLocalOperationProgress> package(details);
    package.Set(opert->ProgressL());
    test(package().iType==TMsvLocalOperationProgress::ELocalNew);
    test(package().iTotalNumberOfEntries==1);
    test(package().iError==aError);
    if (aError)
    {
        test(package().iNumberCompleted==0);
        test(package().iNumberFailed==1);
    }
    else
    {
        test(package().iNumberCompleted==1);
        test(package().iNumberFailed==0);
        TTestMsvEntry* ptr = (TTestMsvEntry*)&aNewEntry;
        ptr->SetId(package().iId);
        ptr->SetParent(aClientEntry.EntryId());
        if (aNewEntry.iType==KUidMsvServiceEntry)
            aNewEntry.iServiceId = aNewEntry.Id();
    }
    test(package().iNumberRemaining==0);
    delete opert;
    opert=NULL;
    CleanupStack::PopAndDestroy(); // active
}
Esempio n. 2
0
LOCAL_C void TestMultipleNotifsL()
{
    CMultipleSessionObserver* ob = new(ELeave) CMultipleSessionObserver;
    CleanupStack::PushL(ob);

    CMsvSession* session = CMsvSession::OpenSyncL(*ob);
    CleanupStack::PushL(session);

    CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
    CleanupStack::PushL(cEntry);

    CEntryObserver* entryOb1=new (ELeave) CEntryObserver;
    CleanupStack::PushL(entryOb1);
    cEntry->AddObserverL(*entryOb1);

    CTestActive* active = new (ELeave) CTestActive;
    CleanupStack::PushL(active);

    CMsvOperation* operation;
    CMsvEntrySelection* selection;

    // create folders to work under
    TMsvEntry folder1;
    folder1.iDescription.Set(KShortDescription);
    folder1.iDetails.Set(KShortDetails);
    folder1.iType = KUidMsvFolderEntry;
    folder1.iMtm = KUidMsvLocalServiceMtm;
    folder1.iServiceId = KMsvLocalServiceIndexEntryId;

    TMsvEntry folder2;
    folder2.iDescription.Set(KShortDescription);
    folder2.iDetails.Set(KShortDetails);
    folder2.iType = KUidMsvFolderEntry;
    folder2.iMtm = KUidMsvLocalServiceMtm;
    folder2.iServiceId = KMsvLocalServiceIndexEntryId;

    TMsvEntry folder3;
    folder3.iDescription.Set(KShortDescription);
    folder3.iDetails.Set(KShortDetails);
    folder3.iType = KUidMsvFolderEntry;
    folder3.iMtm = KUidMsvLocalServiceMtm;
    folder3.iServiceId = KMsvLocalServiceIndexEntryId;

    // create all th entries
    TMsvEntry entry;
    entry.iDescription.Set(KShortDescription);
    entry.iDetails.Set(KShortDetails);
    entry.iType = KUidMsvFolderEntry;
    entry.iMtm = KUidMsvLocalServiceMtm;
    entry.iServiceId = KMsvLocalServiceIndexEntryId;

    // create folder 2 & 3
    cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
    CreateEntry(folder2, *cEntry, KErrNone, *entryOb1);
    CreateEntry(folder3, *cEntry, KErrNone, *entryOb1);

    TMsvLocalOperationProgress prog;

    TInt max = 2*TMsvPackedChangeNotification::KMsvPackedChangeLimit+4;
    for (TInt count=1; count<=max; count++)
    {
        test.Printf(_L("."));

        // create another entry under folder 2
        cEntry->SetEntryL(folder2.Id());
        CreateEntry(entry, *cEntry, KErrNone, *entryOb1);

        // create folder1
        cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
        CreateEntry(folder1, *cEntry, KErrNone, *entryOb1);

        // test
        cEntry->SetEntryL(folder3.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==0);
        delete selection;

        // copy all entries to folder 3
        ob->Start(MMsvSessionObserver::EMsvEntriesCreated, folder3.Id());
        cEntry->SetEntryL(folder2.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        active->StartL();
        operation = cEntry->CopyL(*selection, folder3.Id(), active->iStatus);
        delete selection;
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==count);
        test(prog.iNumberCompleted==count);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        // test
        cEntry->SetEntryL(folder3.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>1)
            test(ob->iSelection.Count()>TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        // test
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>2)
            test(ob->iSelection.Count()>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        test(ob->iSelection.Count()==count);
        ob->Finish();

        // move all entries to folder 1
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        ob->Start(MMsvSessionObserver::EMsvEntriesMoved, folder1.Id(), folder3.Id());
        active->StartL();
        operation = cEntry->MoveL(*selection, folder1.Id(), active->iStatus);
        delete selection;
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==count);
        test(prog.iNumberCompleted==count);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        cEntry->SetEntryL(folder1.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>1)
            test(ob->iSelection.Count()>TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            test(ob->iEvents==1);
            ob->Wait();
            CActiveScheduler::Start();
            test(ob->iEvents==2);
        }
        if (ob->iEvents>2)
            test(ob->iSelection.Count()>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            test(ob->iEvents==2);
            ob->Wait();
            CActiveScheduler::Start();
            test(ob->iEvents==3);
        }
        test(ob->iSelection.Count()==count);
        ob->Finish();


        // delete them
        ob->Start(MMsvSessionObserver::EMsvEntriesDeleted, KMsvGlobalInBoxIndexEntryId);
        cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
        active->StartL();
        operation = cEntry->DeleteL(folder1.Id(), active->iStatus);
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==1);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        if (count+1>TMsvPackedChangeNotification::KMsvPackedChangeLimit && ob->iEvents==1)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        if (count+1>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit && ob->iEvents==2)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        test(ob->iSelection.Count()==count+1);
        ob->Finish();
    }

    test.Printf(_L("\n"));
    CleanupStack::PopAndDestroy(5);
}