コード例 #1
0
/** Checks the start, end and time of an instance
@param	aFetchInstanceArray Array of instances 
@param	aIndex Used to retrieve the correct instance from array
@test
*/
void CTestCalInterimApiTZChange::CheckInstancesTimesL(RPointerArray<CCalInstance>& aFetchInstanceArray, TInt aIndex)
	{
	TDateTime startTime;
	TDateTime endTime;
	CCalInstance* instance = NULL;
	
	GetInstanceDataFromIniFileL(aIndex);
	
	if (iIsFloating)
		{
		instance = aFetchInstanceArray[aIndex];
		startTime = instance->StartTimeL().TimeLocalL().DateTime();
		INFO_PRINTF7(_L("Instance Start Date Year: %d, Month: %d, Day: %d, Instance Start Time Hr: %d, Min: %d, Sec: %d "), startTime.Year(), startTime.Month(), startTime.Day(), startTime.Hour(), startTime.Minute(), startTime.Second());
		TESTL(instance->StartTimeL().TimeLocalL() == instance->Time().TimeLocalL());
		INFO_PRINTF1(_L("Start and Time of instance match"));
		TESTL(FormatDateTime(iPtrExpectedInstanceStart) == instance->StartTimeL().TimeLocalL());
		endTime = instance->EndTimeL().TimeLocalL().DateTime();
		INFO_PRINTF7(_L("Instance End Date Year: %d, Month: %d, Day: %d, Instance Start Time Hr: %d, Min: %d, Sec: %d "), endTime.Year(), endTime.Month(), endTime.Day(), endTime.Hour(), endTime.Minute(), endTime.Second());
		TESTL(FormatDateTime(iPtrExpectedInstanceEnd) == instance->EndTimeL().TimeLocalL());
		TESTL(instance->StartTimeL().TimeMode() == TCalTime::EFloating); // defect stored as fixedutc
		TESTL(instance->Time().TimeMode() == TCalTime::EFloating);
		TESTL(instance->EndTimeL().TimeMode() == TCalTime::EFloating);
		}
	else
		{
		instance = aFetchInstanceArray[aIndex];
		startTime = instance->StartTimeL().TimeUtcL().DateTime();
		INFO_PRINTF7(_L("Instance Start Date Year: %d, Month: %d, Day: %d, Instance Start Time Hr: %d, Min: %d, Sec: %d "), startTime.Year(), startTime.Month(), startTime.Day(), startTime.Hour(), startTime.Minute(), startTime.Second());
		TESTL(instance->StartTimeL().TimeUtcL() == instance->Time().TimeUtcL());
		INFO_PRINTF1(_L("Start and Time of instance match"));
		TESTL(FormatDateTime(iPtrExpectedInstanceStart) == instance->StartTimeL().TimeUtcL());
		endTime = instance->EndTimeL().TimeUtcL().DateTime();
		INFO_PRINTF7(_L("Instance End Date Year: %d, Month: %d, Day: %d, Instance Start Time Hr: %d, Min: %d, Sec: %d "), endTime.Year(), endTime.Month(), endTime.Day(), endTime.Hour(), endTime.Minute(), endTime.Second());
		TESTL(FormatDateTime(iPtrExpectedInstanceEnd) == instance->EndTimeL().TimeUtcL());
		TESTL(instance->StartTimeL().TimeMode() == TCalTime::EFixedUtc);
		TESTL(instance->Time().TimeMode() == TCalTime::EFixedUtc);
		TESTL(instance->EndTimeL().TimeMode() == TCalTime::EFixedUtc);
		}	
	}
コード例 #2
0
// Helper method
// Extract all instances given by Guids in iCurrentTestData
void CDummyCalendarApp::ExtractInstancesL()
	{
	TCalTime startDate;
	startDate.SetTimeLocalL(iCurrentTestData->iStartDate);
	TCalTime endDate;
	endDate.SetTimeLocalL(iCurrentTestData->iEndDate);

	CalCommon::TCalTimeRange timeRange(startDate, endDate);
	
	RPointerArray<CCalInstance> instanceArray;
	
	if (iCurrentTestData->iSearchString)
		{
		CCalInstanceView::TCalSearchParams searchParams(*iCurrentTestData->iSearchString, iCurrentTestData->iSearchBehaviour);
		
		iInstanceView->FindInstanceL(instanceArray, 
									(CalCommon::TCalViewFilter)iCurrentTestData->iFilter, 
									timeRange, 
									searchParams);
		}
	else
		{
		iInstanceView->FindInstanceL(instanceArray, 
							(CalCommon::TCalViewFilter)iCurrentTestData->iFilter, 
							timeRange);		
		}
	
	TBuf<26> startBuf;
	TBuf<26> endBuf;
	startDate.TimeLocalL().FormatL(startBuf,KFormatDate());
	endDate.TimeLocalL().FormatL(endBuf,KFormatDate());
	
	test.Printf(_L("Checking instances between %S and %S\n"), &startBuf, &endBuf);
	
	if (instanceArray.Count() == 0)
		{
		test.Printf(_L("No instances found\n"));
		}
	else
		{
		TInt instanceCount = 0;
		TTime instTime;
		TBuf<26> instBuf;

		while (instanceCount < instanceArray.Count())
			{
			CCalInstance* inst = instanceArray[instanceCount];
			CleanupStack::PushL(inst);

			instTime = inst->Time().TimeLocalL();
			instTime.FormatL(instBuf,KFormatDate());
	
			TBuf<62> rptType;
			TCalRRule rptDef;
			if (!inst->Entry().GetRRuleL(rptDef))
				{
				rptType.Copy(_L("One off"));
				}
			else
				{
				switch (rptDef.Type())
					{
					case TCalRRule::EDaily:
						rptType.Format(_L("Daily every %d days"), rptDef.Interval());
						break;
					case TCalRRule::EWeekly:
						rptType.Format(_L("Weekly every %d weeks"), rptDef.Interval());
						break;
					case TCalRRule::EMonthly:
						rptType.Format(_L("MonthlyByDates every %d months"), rptDef.Interval());
						break;
					case TCalRRule::EYearly:
						rptType.Format(_L("YearlyByDate every %d years"), rptDef.Interval());
						break;
					default:
						ASSERT(0);
						break;
					}
				}
				
			test.Printf(_L("One instance is on %S, %d:%d - %S"), &instBuf, instTime.DateTime().Hour(), instTime.DateTime().Minute(), &rptType);
			
			if (iCurrentTestData->iTimes.Find(instTime) == KErrNotFound)
				{
				test.Printf(_L("THIS ENTRY WAS NOT EXPECTED\n"));
				test(0);
				}
				
			instanceCount++;
			CleanupStack::Pop(inst);
			}
			
		if (iCurrentTestData->iFunction)
			ASSERT(iCurrentTestData->iFunction->CallBack() == 0);
		}

	if (instanceArray.Count() != iCurrentTestData->iTimes.Count())
		{
		test.Printf(_L("Some expected entries were not found!\n"));
		test(0);	
		}
		
	instanceArray.ResetAndDestroy();
	}