pimappservices/calendar/tsrc/TestCalIndexFile/src/TestCalIndexFileAddEntryStep.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "TestCalIndexFileAddEntryStep.h"
       
    17 #include "TestCalIndexFileDefs.h"
       
    18 #include <fbs.h>
       
    19 #include <e32math.h>
       
    20 #include <calcategory.h>
       
    21 #include <caldataexchange.h>
       
    22 #include <caldataformat.h>
       
    23 #include <calsession.h>
       
    24 #include <s32file.h>
       
    25 
       
    26 
       
    27 CTestCalIndexFileAddEntryStep::~CTestCalIndexFileAddEntryStep()
       
    28 /**
       
    29  * Destructor
       
    30  */
       
    31 	{
       
    32 	}
       
    33 
       
    34 CTestCalIndexFileAddEntryStep::CTestCalIndexFileAddEntryStep()
       
    35 /**
       
    36  * Constructor
       
    37  */
       
    38 	{
       
    39 	// **MUST** call SetTestStepName in the constructor as the controlling
       
    40 	// framework uses the test step name immediately following construction to set
       
    41 	// up the step's unique logging ID.
       
    42 	SetTestStepName(KTestCalIndexFileAddEntryStep);
       
    43 	}
       
    44 
       
    45 
       
    46 TVerdict CTestCalIndexFileAddEntryStep::doTestStepPostambleL()
       
    47 	{
       
    48 	return TestStepResult();
       
    49 	}
       
    50 
       
    51 TVerdict CTestCalIndexFileAddEntryStep::doTestStepL()
       
    52 	{
       
    53 	// this method assumes a pass. Checks that fail will stop
       
    54 	// the test step. If this method Leaves, then the TEF will 
       
    55 	// catch it and the step will not be recorded as a pass.
       
    56 	
       
    57 	SetUpCalDirL();
       
    58 	
       
    59 	AddCalendarFileL();
       
    60 	AddIndexFileL();
       
    61 	OpenAgendaL();
       
    62 	
       
    63 	// use the base class version of ValidateDbContentsL as 
       
    64 	// we have not added the entry
       
    65 	if (!CTestCalIndexFileStepBase::ValidateDbContentsL())
       
    66 		{
       
    67 		INFO_PRINTF1(_L("Add Entry Step Failed validating DB contents before entry addition"));
       
    68 		CloseAgendaL();
       
    69 		SetTestStepResult(EFail);
       
    70 		return EFail;
       
    71 		}
       
    72 		
       
    73 	AddEntryL();
       
    74 	// The index file should be deleted as it is now out of date.
       
    75 	// It will be rebuilt when the session closes.
       
    76 	if (CheckIndexFilePresentL())
       
    77 		{
       
    78 		INFO_PRINTF1(_L("Add Entry Step Failed - index file present when dirty"));
       
    79 		CloseAgendaL();
       
    80 		SetTestStepResult(EFail);
       
    81 		return EFail;
       
    82 		}
       
    83 		
       
    84 	CloseAgendaL();
       
    85 	if (!CheckIndexFilePresentL())
       
    86 		{
       
    87 		INFO_PRINTF1(_L("Add Entry Step Failed - no index file created after add and close"));
       
    88 		SetTestStepResult(EFail);
       
    89 		return EFail;
       
    90 		}
       
    91 		
       
    92 	// make sure the added entry is still there
       
    93 	OpenAgendaL();
       
    94 	if (!ValidateDbContentsL(ETrue))
       
    95 		{
       
    96 		INFO_PRINTF1(_L("Add Entry Step Failed validating DB contents after addition"));
       
    97 		CloseAgendaL();
       
    98 		SetTestStepResult(EFail);
       
    99 		return EFail;
       
   100 		}	
       
   101 	CloseAgendaL();
       
   102 
       
   103 	SetTestStepResult(EPass);
       
   104 	return EPass;
       
   105 	}
       
   106 
       
   107 
       
   108 void CTestCalIndexFileAddEntryStep::GetEntryInfoFromConfigL(RPointerArray<CConfigTestEntryInfo>& aEntriesInfo, TInt& aNumEntries, TBool aPerformCrudOps)
       
   109 	{
       
   110 	// first get the default entries from the file
       
   111 	CTestCalIndexFileStepBase::GetEntryInfoFromConfigL(aEntriesInfo, aNumEntries, aPerformCrudOps);
       
   112 	
       
   113 	if (aPerformCrudOps)
       
   114 		{
       
   115 		// now add the new entry info to the list
       
   116 		TPtrC entryString;
       
   117 		TBool readRes = EFalse;
       
   118 		readRes = GetStringFromConfig(ConfigSection(), KAddEntry, entryString);
       
   119 		if (!readRes)
       
   120 			{
       
   121 			INFO_PRINTF1(_L("Error in CTestCalIndexFileAddEntryStep::GetEntryInfoFromConfigL - entrytoadd not found in config file"));
       
   122 			User::Leave(KErrNotFound);
       
   123 			}
       
   124 		CConfigTestEntryInfo* inf = new(ELeave)CConfigTestEntryInfo();
       
   125 		CleanupStack::PushL(inf);
       
   126 		ParseEntryStringL(*inf, entryString);
       
   127 		aEntriesInfo.Append(inf);
       
   128 		CleanupStack::Pop(inf); // now held in array
       
   129 		aNumEntries++;
       
   130 		}
       
   131 	}
       
   132 
       
   133