landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp108.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 // INCLUDE FILES
       
    21 #include "FT_CPosTp667.h"
       
    22 
       
    23 #include <EPos_CPosLmDatabaseManager.h>
       
    24 #include <EPos_CPosLandmarkDatabase.h>
       
    25 #include <EPos_CPosLandmarkCategory.h>
       
    26 #include <EPos_CPosLmCategoryManager.h>
       
    27 
       
    28 // CONSTANTS
       
    29 _LIT(KSetCapPath, "c:\\sys\\bin\\setcap.exe");
       
    30 // Nr of tests in this TP
       
    31 const TInt KNrOfTests = 6;
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 
       
    35 // Destructor
       
    36 CPosTp667::~CPosTp667()
       
    37     {
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------
       
    41 // CPosTp667::GetName
       
    42 //
       
    43 // (other items were commented in a header).
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 
       
    47 void CPosTp667::GetName(TDes& aName) const
       
    48     {
       
    49     _LIT(KTestName0, "SetCap-TP108");
       
    50     aName = KTestName0;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CPosTp667::StartL
       
    55 //
       
    56 // (other items were commented in a header).
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 void CPosTp667::StartL()
       
    60     {
       
    61     iLog->Put(_L("StartL"));
       
    62     
       
    63     SetupTestPartL(0);
       
    64     SetupTestPartL(1);
       
    65     SetupTestPartL(2);
       
    66     SetupTestPartL(3);
       
    67     SetupTestPartL(4);
       
    68     SetupTestPartL(5);
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CPosTp667::SetupTestPartL
       
    73 //
       
    74 // (other items were commented in a header).
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 void CPosTp667::SetupTestPartL(TInt aIndex)
       
    78     {
       
    79     iLog->Put(_L("StartL(TInt aIndex)"));
       
    80 /* 
       
    81 #ifdef __WINS__
       
    82 	_LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!");
       
    83 	LogErrorAndLeave(KNotOnWins);		
       
    84 	
       
    85 #endif
       
    86 */
       
    87 TBuf<20> capability;
       
    88 switch (aIndex)
       
    89 {
       
    90     case 0:
       
    91     iLog->Put(_L("Part1"));
       
    92     capability.Zero();
       
    93     // Set to no capablities at all
       
    94     capability.Append(_L("0"));
       
    95     break;
       
    96     
       
    97     case 1:
       
    98     iLog->Put(_L("Part2"));
       
    99     // Set to ReadUserData
       
   100     capability.Append(_L("8000"));
       
   101     break;
       
   102     
       
   103     case 2:
       
   104     iLog->Put(_L("Part3"));
       
   105     // Set to WriteUserData
       
   106     capability.Append(_L("10000"));
       
   107     break;
       
   108     
       
   109     case 3:
       
   110     iLog->Put(_L("Part4"));
       
   111     // Set to ReadUserData and WriteUserData
       
   112     capability.Append(_L("18000"));
       
   113     break;
       
   114     
       
   115     case 4:
       
   116     iLog->Put(_L("Part5"));
       
   117     // Set to WriteDeviceData
       
   118     capability.Append(_L("20"));
       
   119     break;
       
   120     
       
   121     case 5:
       
   122     iLog->Put(_L("Part6"));
       
   123     // Set to ReadUserData, WriteUserData and WriteDeviceData
       
   124     capability.Append(_L("18020"));
       
   125     break;        
       
   126     
       
   127     default:
       
   128     iLog->Put(_L("Default"));
       
   129     LogErrorAndLeave(_L("We should never come here"));
       
   130     break;
       
   131 }
       
   132     // Only for target, on winscw use bat-script
       
   133 	RProcess execlient;
       
   134 	RFile file;
       
   135 	RFs fileSession;
       
   136 	User::LeaveIfError(fileSession.Connect());
       
   137 	CleanupClosePushL(fileSession);
       
   138 	CleanupClosePushL(file);
       
   139 	CFileMan* fileMan = CFileMan::NewL(fileSession);
       
   140 	CleanupStack::PushL(fileMan);	
       
   141 
       
   142     TBuf<100> buf;
       
   143 
       
   144     buf.Append(_L("CapabilityTests.exe "));
       
   145     buf.Append(capability);
       
   146     buf.Append(_L(" CapabilityTests_tmp.exe"));
       
   147 
       
   148     // Make call to SetCap
       
   149 	TInt result = execlient.Create(KSetCapPath, 
       
   150 		//_L("CapabilityTests.exe 3FFFF CapabilityTests_All.exe"),
       
   151 		buf,
       
   152 		TUidType(KNullUid, KNullUid, KNullUid));
       
   153 	User::LeaveIfError(result);
       
   154 	execlient.Resume();	//make the execlient visible
       
   155 	User::After(800000); //Wait 0.8 s
       
   156 	
       
   157 	execlient.Close(); //Close handle to exe-client
       
   158 		
       
   159 	// now move file CapabilityTests_tmp.exe to CapabilityTests.exe
       
   160 	TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite);
       
   161 	if (err != KErrNone)
       
   162 	    {
       
   163 	    iLog->Put(_L("Move problem"));
       
   164 	    LogErrorAndLeave(_L("Move problem"), err);
       
   165 	    }
       
   166 
       
   167 	CleanupStack::PopAndDestroy(fileMan); //fileMan
       
   168 	CleanupStack::PopAndDestroy(&file); //file
       
   169 	CleanupStack::PopAndDestroy(&fileSession); //fileSession
       
   170 
       
   171     // Prepare test conditions
       
   172     SetupTestEnvironmentL();
       
   173     
       
   174     buf.Zero();
       
   175     buf.Format(_L("SetCap done, Now Execute CapabilityTest TP108, part %d"), aIndex+1);
       
   176     TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse);
       
   177     //if(answer == EUtfwUserAnswerNo)
       
   178 	}
       
   179 
       
   180 // ---------------------------------------------------------
       
   181 // CPosTp667::SetupTestEnvironmentL
       
   182 //
       
   183 // (other items were commented in a header).
       
   184 // ---------------------------------------------------------
       
   185 //
       
   186 void CPosTp667::SetupTestEnvironmentL()
       
   187     {
       
   188     iLog->Put(_L("SetupTestEnvironmentL"));
       
   189     
       
   190     // Setup start conditions for compatibility test
       
   191     _LIT(KDefaultDb, "file://c:eposlm.ldb");
       
   192 
       
   193     CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL();
       
   194     CleanupStack::PushL(dbManager);
       
   195     
       
   196     // Remove all landmark databases
       
   197     CDesCArray* uris = dbManager->ListDatabasesL();
       
   198     CleanupStack::PushL(uris);
       
   199     for (TInt i = 0; i < uris->Count(); i++)
       
   200         {
       
   201         dbManager->DeleteDatabaseL((*uris)[i]);
       
   202         }
       
   203     CleanupStack::PopAndDestroy(uris);
       
   204         
       
   205     // Create and initialize a default database
       
   206     dbManager->CreateDatabaseL(KDefaultDb);
       
   207     dbManager->SetDefaultDatabaseL(KDefaultDb);
       
   208     CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL();
       
   209     CleanupStack::PushL(database);
       
   210     ExecuteAndDeleteLD(database->InitializeL());
       
   211     
       
   212     // Add 5 landmarks - will generate ids 1 - 5
       
   213     const TInt KFive = 5;
       
   214     for (TInt j = 0; j < KFive; j++)
       
   215         {
       
   216         CPosLandmark* lm = CPosLandmark::NewLC();
       
   217         lm->SetLandmarkNameL(_L("Landmark"));
       
   218         database->AddLandmarkL(*lm);
       
   219         CleanupStack::PopAndDestroy(lm);
       
   220         }
       
   221         
       
   222     // Add 5 categories
       
   223     CPosLmCategoryManager* catManager = CPosLmCategoryManager::NewL(*database);
       
   224     CleanupStack::PushL(catManager);
       
   225     for (TInt k = 0; k < KFive; k++)
       
   226         {
       
   227         CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC();
       
   228         TBuf<15> name;
       
   229         name = _L("Category ");
       
   230         name.AppendNum(k);
       
   231         category->SetCategoryNameL(name);
       
   232         catManager->AddCategoryL(*category);
       
   233         CleanupStack::PopAndDestroy(category);
       
   234         }
       
   235        
       
   236     CleanupStack::PopAndDestroy(3, dbManager);
       
   237     }
       
   238 
       
   239 // End of File