landmarks/locationlandmarks/tsrc/LandmarkTestModule/src/FT_CPosTp76.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 #include "FT_CPosTp76.h"
       
    22 #include <EPos_CPosLandmarkDatabase.h>
       
    23 #include "FT_LandmarkConstants.h"
       
    24            
       
    25 //_LIT(KCopyFilePath, "c:\\system\\data\\EPOSLMGLOBALCATEGORIES.R01");
       
    26 _LIT(KCopyFilePath, "c:\\resource\\EPOSLMGLOBALCATEGORIES.R01");
       
    27 #ifdef __WINS__
       
    28 _LIT(KCORRUPTFILE, "z:\\system\\test\\testdata\\corrupt_EPOSLMGLOBALCATEGORIES.R06");
       
    29 #else
       
    30 _LIT(KCORRUPTFILE, "c:\\system\\test\\testdata\\corrupt_EPOSLMGLOBALCATEGORIES.R06");
       
    31 #endif
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 
       
    35 // ---------------------------------------------------------
       
    36 // CPosTp76::GetName
       
    37 //
       
    38 // (other items were commented in a header).
       
    39 // ---------------------------------------------------------
       
    40 //
       
    41 void CPosTp76::GetName(TDes& aName) const
       
    42     {
       
    43     _LIT(KTestName, "Tp76 - Corrupt Global Categories resource file");
       
    44     aName = KTestName;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CPosTp76::StartL
       
    49 //
       
    50 // (other items were commented in a header).
       
    51 // ---------------------------------------------------------
       
    52 //
       
    53 void CPosTp76::StartL()
       
    54     {  
       
    55     
       
    56     // Test error report ESLI-65WADU
       
    57 	TestCorruptGlobalCategoriesFileL();
       
    58 
       
    59 	}
       
    60 
       
    61 // ---------------------------------------------------------
       
    62 // CPosTp76::CloseTest
       
    63 //
       
    64 // (other items were commented in a header).
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 void CPosTp76::CloseTest()
       
    68 	{
       
    69 	iLog->Put(_L("CloseTest"));
       
    70 	// Delete "corrupt" global categories file
       
    71 	DeleteFileL(KCopyFilePath);
       
    72 
       
    73 	delete iOperation;
       
    74 	iOperation = NULL;
       
    75 
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CPosTp76::TestCorruptGlobalCategoriesFileL
       
    80 //
       
    81 // (other items were commented in a header).
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 void CPosTp76::TestCorruptGlobalCategoriesFileL()
       
    85 	{
       
    86 	iLog->Put(_L("TestCorruptGlobalCategoriesFileL"));
       
    87 	RemoveDefaultDbL();
       
    88 
       
    89 	RFs fs;
       
    90     User::LeaveIfError(fs.Connect());
       
    91     CleanupClosePushL(fs);
       
    92     
       
    93     CFileMan* fileMan = CFileMan::NewL(fs);
       
    94     CleanupStack::PushL(fileMan);
       
    95    
       
    96 	// use emtpy landmarks db as corrupt global categories file
       
    97     //User::LeaveIfError(fileMan->Copy(KLandmarksEmptyDb, KCopyFilePath, CFileMan::EOverWrite));
       
    98     User::LeaveIfError(fileMan->Copy(KCORRUPTFILE, KCopyFilePath, CFileMan::EOverWrite));
       
    99      
       
   100     CleanupStack::PopAndDestroy(2, &fs);
       
   101 	iLog->Put(_L("Open Landmarksdb"));
       
   102 	CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL();
       
   103     CleanupStack::PushL(lmd);
       
   104 
       
   105 	if (lmd->IsInitializingNeeded())
       
   106         {
       
   107 		iLog->Put(_L("IsInitializingNeeded()"));
       
   108         ExecuteAndDeleteLD(lmd->InitializeL());
       
   109         iLog->Put(_L("After InitializeL()"));
       
   110 		}
       
   111 
       
   112     // FrBo TBD below, what will happen below when error above is fixed
       
   113 	CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*lmd);
       
   114 	CleanupStack::PushL(categoryManager);
       
   115 	// Make sure that global categories are included in lm db, use default global categories
       
   116 	iLog->Put(_L("categoryManager->ResetGlobalCategoriesL()"));
       
   117 	
       
   118 	TRAPD(err, iOperation = categoryManager->ResetGlobalCategoriesL());
       
   119 
       
   120 	if (err == KErrNone) LogErrorAndLeave(_L("ResetGlobalCategoriesL should leave with errorcode"));
       
   121 	TBuf<100> buf;
       
   122 	buf.Format(_L("ResetGlobalCategoriesL leaved with code: %d"), err);
       
   123 	iLog->Put(buf);
       
   124 
       
   125 	delete iOperation;
       
   126 	iOperation = NULL;
       
   127 
       
   128 	CleanupStack::PopAndDestroy(categoryManager);
       
   129     CleanupStack::PopAndDestroy(lmd);
       
   130 
       
   131 	DeleteFileL(KCopyFilePath);
       
   132 	iLog->Put(_L("TestCorruptGlobalCategoriesFileL"));
       
   133 	}
       
   134 
       
   135 //  End of File