landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp81.cpp
branchRCL_3
changeset 44 2b4ea9893b66
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *   ?description_line
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 
       
    22 #include "FT_CPosTp81.h"
       
    23 #include <EPos_CPosLandmarkDatabase.h>
       
    24 #include <EPos_CPosLmDatabaseManager.h>
       
    25            
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 // ---------------------------------------------------------
       
    29 // CPosTp81::GetName
       
    30 //
       
    31 // (other items were commented in a header).
       
    32 // ---------------------------------------------------------
       
    33 //
       
    34 void CPosTp81::GetName(TDes& aName) const
       
    35     {
       
    36     _LIT(KTestName, "Tp81 - category with apostrophe in name (SBUY-6A9A5B)");
       
    37     aName = KTestName;
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------
       
    41 // CPosTp81::StartL
       
    42 //
       
    43 // (other items were commented in a header).
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 void CPosTp81::StartL()
       
    47     {
       
    48     _LIT(KCategoryName, "Category with apostrophe'");
       
    49     _LIT(KCategoryName2, "Category with apostrophe(')");
       
    50     
       
    51     RemoveAllLmDatabasesL();
       
    52 
       
    53     CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL();
       
    54     CleanupStack::PushL(db);
       
    55     if (db->IsInitializingNeeded())
       
    56        {
       
    57        ExecuteAndDeleteLD(db->InitializeL()); // Synchronous since no argument
       
    58        }
       
    59     
       
    60     CPosLmCategoryManager* manager = CPosLmCategoryManager::NewL(*db);
       
    61     CleanupStack::PushL(manager);
       
    62     
       
    63     // Test with only apostrophe
       
    64     CPosLandmarkCategory* cat = CPosLandmarkCategory::NewL();
       
    65     CleanupStack::PushL(cat);
       
    66     iLog->Put(_L("Set name with apostrophe"));
       
    67     cat->SetCategoryNameL(KCategoryName); 
       
    68     iLog->Put(_L("AddCategory with apostrophe in name"));
       
    69     TPosLmItemId id = manager->AddCategoryL(*cat);
       
    70     User::After(200000);
       
    71     iLog->Put(_L("AddCategory was succesful"));
       
    72     CleanupStack::PopAndDestroy(cat);
       
    73     
       
    74     CPosLandmarkCategory* category = manager->ReadCategoryLC(id);
       
    75     TPtrC catName;
       
    76     category->GetCategoryName(catName);
       
    77     iLog->Put(catName);
       
    78     if (catName.CompareC(KCategoryName) != KErrNone) iLog->Put(_L("ERROR: Names are not equal"));
       
    79     CleanupStack::PopAndDestroy(category);
       
    80     CleanupStack::PopAndDestroy(manager);
       
    81     
       
    82     // Test with apostrophe and paranthesis
       
    83     manager = CPosLmCategoryManager::NewL(*db);
       
    84     CleanupStack::PushL(manager);
       
    85     
       
    86     cat = CPosLandmarkCategory::NewL();
       
    87     CleanupStack::PushL(cat);
       
    88     iLog->Put(_L("Set name with apostrophe"));
       
    89     cat->SetCategoryNameL(KCategoryName2); 
       
    90     iLog->Put(_L("AddCategory with apostrophe and paranthesis in name"));
       
    91     id = manager->AddCategoryL(*cat);
       
    92     User::After(200000);
       
    93     iLog->Put(_L("AddCategory was succesful"));
       
    94     CleanupStack::PopAndDestroy(cat);
       
    95     
       
    96     category = manager->ReadCategoryLC(id);
       
    97     category->GetCategoryName(catName);
       
    98     iLog->Put(catName);
       
    99     if (catName.CompareC(KCategoryName2) != KErrNone) iLog->Put(_L("ERROR: Names are not equal (2)"));
       
   100     CleanupStack::PopAndDestroy(category);
       
   101     
       
   102     ExecuteAndDeleteLD(db->CompactL());
       
   103 
       
   104     CleanupStack::PopAndDestroy(manager);
       
   105     CleanupStack::PopAndDestroy(db);
       
   106 
       
   107     TestDifferentNamesL();
       
   108     
       
   109     }
       
   110 // ---------------------------------------------------------
       
   111 // CPosTp81::TestDifferentNamesL
       
   112 //
       
   113 // (other items were commented in a header).
       
   114 // ---------------------------------------------------------
       
   115 //
       
   116 void CPosTp81::TestDifferentNamesL()
       
   117     {
       
   118     iLog->Put(_L("TestDifferentNamesL"));        
       
   119     ////////////////////////////////////////////////////////////
       
   120     _LIT(KCategory1, "file://:://c:::en helt \" sjuk .ldb databas\".ldb.ldb.ldb");
       
   121     _LIT(KCategory2, "file://c:en helt sjuk databas.ldb");
       
   122     _LIT(KCategory3, "le:///c:en helt sjuk databas.ldb");
       
   123     _LIT(KCategory4, "/c::en helt sjuk databas.ldb");
       
   124     _LIT(KCategory5, "en helt sjuk .ldb databas.ldb");
       
   125     _LIT(KCategory6, "en helt sjuk databas.ldb.ldb.ldb");
       
   126     _LIT(KCategory7, "en helt \" sjuk databas.ldb");
       
   127     _LIT(KCategory8, "en helt < sjuk databas.ldb");
       
   128     _LIT(KCategory9, "en helt > sjuk databas.ldb");
       
   129     _LIT(KCategory10, "en helt | sjuk databas.ldb");
       
   130     _LIT(KCategory11, "en helt / sjuk databas.ldb");
       
   131     _LIT(KCategory12, "en helt ? sjuk databas.ldb");
       
   132     _LIT(KCategory13, "en helt \\ sjuk databas.ldb");
       
   133     _LIT(KCategory14, "en helt : sjuk databas.ldb");
       
   134     _LIT(KCategory15, ":!#¤%&()=+`´^¨~'§½-_,;.{}[]$£@0123456789åäöÅÄÖ.ldb");
       
   135     _LIT(KCategory16, "file://c:qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM.ldb");
       
   136     _LIT(KCategory17, "file://en otroligt helt sjuk databas.ldb");
       
   137     _LIT(KCategory18, "c:en helsjuk databas.ldb");
       
   138     _LIT(KCategory19, "file://c:\\system\\data\\en helt sjuk databas.ldb");
       
   139     _LIT(KCategory20, "file://c:.ldb");
       
   140     _LIT(KCategory21, "file://c:filename");
       
   141     _LIT(KCategory22, "file://c:filename.dip");
       
   142     _LIT(KCategory23, "file://c:filename. ldb");
       
   143     _LIT(KCategory24, "file://c:*.ldb");
       
   144     _LIT(KCategory25, "file://allan:en helt sjuk databas.ldb");
       
   145     _LIT(KCategory26, "file://g:en helt sjuk databas.ldb");
       
   146     _LIT(KCategory27, "file://c:filename.ldb");
       
   147     _LIT(KCategory28, "file://c:012345678901234567890123456789012345678901234567890123456789.ldb");
       
   148     
       
   149     const TInt KNrOfUris = 28;
       
   150     const TDesC* listOfCategories[] = {&KCategory1, &KCategory2, &KCategory3 ,&KCategory4, &KCategory5, &KCategory6,
       
   151      &KCategory7, &KCategory8, &KCategory9
       
   152     , &KCategory10, &KCategory11, &KCategory12, &KCategory13, &KCategory14, &KCategory15
       
   153     , &KCategory16, &KCategory17, &KCategory18, &KCategory19, &KCategory20, &KCategory21
       
   154     , &KCategory22, &KCategory23, &KCategory24, &KCategory25, &KCategory26, &KCategory27, &KCategory28};
       
   155 
       
   156 /*
       
   157     const TInt KNrOfNonWorkingUris = 19;
       
   158     const TDesC* listOfUrisNonWorking[] = {&KCategory1, &KCategory3 ,&KCategory4, &KCategory7, &KCategory8, &KCategory9
       
   159     , &KCategory10, &KCategory11, &KCategory12, &KCategory13, &KCategory14, &KCategory19, &KCategory20, &KCategory21
       
   160     , &KCategory22, &KCategory23, &KCategory24, &KCategory25, &KCategory26};
       
   161     
       
   162     TInt errorList[] = {KErrBadName, KErrBadName, KErrBadName, KErrBadName, KErrBadName ,KErrBadName,KErrBadName,
       
   163                    KErrBadName, KErrBadName, KErrArgument, KErrBadName, KErrArgument, KErrArgument,
       
   164                    KErrArgument, KErrArgument,KErrArgument, KErrBadName, KErrBadName, KErrNotReady};
       
   165                    */
       
   166     //////////////////////////////////////////////////
       
   167     
       
   168     CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL();
       
   169     CleanupStack::PushL(db);
       
   170     
       
   171     CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*db);
       
   172     CleanupStack::PushL(categoryManager);
       
   173     
       
   174     TBuf<100> buf;
       
   175     
       
   176     for (TInt i=0;i<KNrOfUris;i++)
       
   177         {
       
   178         CPosLandmarkCategory* cat = CPosLandmarkCategory::NewL();
       
   179         CleanupStack::PushL(cat);
       
   180         iLog->Put(_L("Set name to:"));
       
   181         iLog->Put(*listOfCategories[i]);
       
   182         TRAPD(err, cat->SetCategoryNameL(*listOfCategories[i]));
       
   183         if (err == KErrNone)
       
   184             {
       
   185             iLog->Put(_L("AddCategory"));
       
   186             TPosLmItemId id = -1;
       
   187             TRAPD(err2, id = categoryManager->AddCategoryL(*cat));
       
   188             User::After(200000);
       
   189             if (err2 != KErrNone)
       
   190                 {
       
   191                 buf.Format(_L("Error %d from AddCategoryL"), err2);
       
   192                 LogErrorAndLeave(buf);
       
   193                 }
       
   194             else
       
   195                 {
       
   196                 buf.Format(_L("Checking landmark with id %d"), id);
       
   197                 iLog->Put(buf);
       
   198                 
       
   199                 CPosLandmarkCategory* category = categoryManager->ReadCategoryLC(id);
       
   200                 User::After(200000);
       
   201                 TPtrC catName;
       
   202                 category->GetCategoryName(catName);
       
   203                 iLog->Put(catName);
       
   204                 if (catName.CompareC(*listOfCategories[i]) != KErrNone) iLog->Put(_L("ERROR: Names are not equal"));
       
   205                 CleanupStack::PopAndDestroy(category);
       
   206                 }
       
   207             }
       
   208         else
       
   209             {
       
   210             buf.Format(_L("Error %d from SetCategoryNameL"), err);
       
   211             LogErrorAndLeave(buf);
       
   212             }
       
   213         CleanupStack::PopAndDestroy(cat);
       
   214         ExecuteAndDeleteLD(db->CompactL());
       
   215         }
       
   216     
       
   217     CleanupStack::PopAndDestroy(categoryManager);
       
   218     CleanupStack::PopAndDestroy(db);
       
   219     }
       
   220 //  End of File