summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/integration/testimpexvcard/src/testexbdaylocal.cpp
blob: 4c6170c8fbbad22b4a9fca7cdb4d687167290226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include "testexbdaylocal.h"

CTestExBDayLocal::~CTestExBDayLocal()
/**
 * Destructor
 */
	{
	}

CTestExBDayLocal::CTestExBDayLocal()
/**
 * Constructor
 */
	{
	// Call base class method to set up the human readable name for logging
	SetTestStepName(KTestExBDayLocal);
	}

TVerdict CTestExBDayLocal::doTestStepPreambleL()
/**
 * @return - TVerdict code
 * Override of base class virtual
 */
	{
	INFO_PRINTF1(_L("Start Export of vCards (birthday in Local) Tests"));
	
	iScheduler = new (ELeave) CActiveScheduler;
	CActiveScheduler::Install(iScheduler);
	
	SetTestStepResult(EPass);
	return TestStepResult();
	}

TBool CTestExBDayLocal::CheckImportedBDay()
	{
	TDateTime importedDateTime = iBDayFromImport.DateTime();
	TDateTime exportedDateTime = iBDayLocal.DateTime();
	
	//checks if exported and imported birthday macthes, which it should, otherwise test failed
	if((importedDateTime.Year() != exportedDateTime.Year()) ||
	 (importedDateTime.Month() != exportedDateTime.Month()) ||
	 (importedDateTime.Day() != exportedDateTime.Day()) )
		{
		INFO_PRINTF1(_L("Export and Import of birthday does not match (incorrect)"));
		return EFalse;
		}
	else
		{
		INFO_PRINTF1(_L("Export and Import of birthday macthes (correct)"));
		return ETrue;
		}	
	}
	
TVerdict CTestExBDayLocal::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 */
	{
	SetTestStepResult(EFail);
	
	TInt numberOfCases = 0;
	
	while (ETrue)
		{
		TPtrC ptrBDay = GetBDayL(numberOfCases);
		if(ptrBDay==KNullDesC)
			{
			break;	
			}
		
		INFO_PRINTF2(_L("TEST: %d"), numberOfCases+1);
				
		iBDayLocal = FormatDateTime(ptrBDay);
		TDateTime t = iBDayLocal.DateTime();
		INFO_PRINTF7(_L("Birthday to be exported, Year: %d, Month: %d, Day: %d, Hr: %d, Min: %d, Sec: %d"), t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second());
				
		iName = GetNameL(numberOfCases);
		
		iPhone = GetPhoneL(numberOfCases);
		
		TBuf<90> pathVCF(KExportBDayFile);
		ExportItemL(pathVCF, ETrue);
		// read from the disk.
		ImportItemL(pathVCF, ETrue);
		
		if(!CheckImportedBDay())
			{
			SetTestStepResult(EFail);
			return TestStepResult();
			}
			
		numberOfCases++;
		}// End Of While Loop
		
	SetTestStepResult(EPass);
	return TestStepResult();
	}

TVerdict CTestExBDayLocal::doTestStepPostambleL()
/**
 * @return - TVerdict code
 * Override of base class virtual
 */
	{
	CActiveScheduler::Install(NULL);
	delete iScheduler;
	INFO_PRINTF1(_L("Completed Export of vCards (birthday in Local) Tests"));
	return TestStepResult();
	}

TPtrC CTestExBDayLocal::GetBDayL(TInt numberOfCases)
	{
	TPtrC bDay;
	
	TPtrC config = KVCard();
	HBufC *configval = HBufC::NewLC(config.Length()+2);
	
	TPtr configSection = configval->Des();
	
	configSection.Append(config);
	configSection.AppendNum(numberOfCases);
	
	GetStringFromConfig(configSection,KBDayLocal,bDay);
	
	CleanupStack::PopAndDestroy(configval);
	
	return bDay;
	}
	
TPtrC CTestExBDayLocal::GetNameL(TInt numberOfCases)
	{
	TPtrC name;
	
	TPtrC config = KVCard();
	HBufC *configval = HBufC::NewLC(config.Length()+2);
	
	TPtr configSection = configval->Des();
	
	configSection.Append(config);
	configSection.AppendNum(numberOfCases);
	
	GetStringFromConfig(configSection,KName,name);
	
	CleanupStack::PopAndDestroy(configval);
	
	return name;
	}
	
TPtrC CTestExBDayLocal::GetPhoneL(TInt numberOfCases)
	{
	TPtrC phone;
	
	TPtrC config = KVCard();
	HBufC *configval = HBufC::NewLC(config.Length()+2);
	
	TPtr configSection = configval->Des();
	
	configSection.Append(config);
	configSection.AppendNum(numberOfCases);
	
	GetStringFromConfig(configSection,KPhone,phone);
	
	CleanupStack::PopAndDestroy(configval);
	
	return phone;
	}