Ejemplo n.º 1
0
/** Gets the current system time zone in OOM conditions
*/
void CTestTZServer::OOMGetCurrentTimeZoneL()
	{
	RTz tz;
	CleanupClosePushL(tz);
	User::LeaveIfError(tz.Connect());
	
	CTzId* tzId = NULL;

	iFailAt = 1;
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		TRAPD(err,tzId = tz.GetTimeZoneIdL());
		 
		if ( err == KErrNone )
			{
			TESTL(tzId != NULL);
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of GetTimeZoneIdL()) Api is done"));
			break;
			}
				
		if ( ErrorProcess(err) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}
		}	
	
	CleanupStack::PopAndDestroy(&tz);
	}
Ejemplo n.º 2
0
/** Retrieves daylight property for various time zones in OOM conditions
*/
void CTestTZServer::OOMDaylightSavingL()
	{
	RTz tz;
	CleanupClosePushL(tz);
	User::LeaveIfError(tz.Connect());

	tz.SetAutoUpdateBehaviorL(RTz::ETZAutoDSTUpdateOn);

	CTzId* tzId = NULL;

	TRAPD(err1,tzId = tz.GetTimeZoneIdL()); //the current system time zone
	TESTL ( err1 == KErrNone );
	
	CleanupStack::PushL(tzId);
		
	TBool isDaylightOn = EFalse;
	
	iFailAt = 0;
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		TRAPD(err, isDaylightOn = tz.IsDaylightSavingOnL(*tzId)); //daylight property for current system time zone
		 
		if ( err == KErrNone )
			{
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of IsDaylightSavingOnL()) Api is done"));
			break;
			}
				
		if ( ErrorProcess(err) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}
		}	
	
	iField.Zero();
	iField.Append(KDaylightSaving);
	GetBoolFromConfig(ConfigSection(),iField,iDaylightSaving); //gets expected daylight property
	
	//compares expected daylight property with actual daylight property
	TESTL(iDaylightSaving == isDaylightOn);
	
	CleanupStack::PopAndDestroy(tzId);
	CleanupStack::PopAndDestroy(&tz);
	}
Ejemplo n.º 3
0
/** Retrives offsets for various numeric ids in OOM conditions
*/
void CTestTZServer::OOMGetOffsetTZIdsL()
	{
	RArray<TPtrC>	numericIdsList;
	CleanupClosePushL(numericIdsList);
	
	TPtrC numericids;
	GetStringFromConfig(ConfigSection(), KNumericIds, numericids);
	TokenizeStringL(numericids, numericIdsList); //retrieve numeric ids to obtain their offsets
	
	RArray<TInt> tzIds;
	CleanupClosePushL(tzIds);
	
	for (TInt i = 0; i < numericIdsList.Count(); i++)
		{
		TLex lex(numericIdsList[i]);
		TInt numericId;
		User::LeaveIfError(lex.Val(numericId));
		tzIds.Append(numericId);
		}
	
	RTz tz;
	CleanupClosePushL(tz);
	User::LeaveIfError(tz.Connect());

	tz.SetAutoUpdateBehaviorL(RTz::ETZAutoDSTUpdateOn);

	RArray<TInt> offsets;
	CleanupClosePushL(offsets);
		
	iFailAt = 1;
	
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		offsets.Reset();
		TRAPD(err,tz.GetOffsetsForTimeZoneIdsL(tzIds,offsets));
		 
		if ( err == KErrNone )
			{
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of GetOffsetsForTimeZoneIdsL Api is done"));
			break;
			}
				
		if ( ErrorProcess(err) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}
		}		
	
	RArray<TPtrC>	expectedOffsetList;
	CleanupClosePushL(expectedOffsetList);
	
	TPtrC expectedOffsets;
	GetStringFromConfig(ConfigSection(), KOffset, expectedOffsets);
	TokenizeStringL(expectedOffsets, expectedOffsetList); //gets the expected offsets for the specified numeric ids
	
	RArray<TInt> expectedOffsetsList;
	CleanupClosePushL(expectedOffsetsList);
	
	for (TInt i = 0; i < expectedOffsetList.Count(); i++)
		{
		TLex lex(expectedOffsetList[i]);
		TInt offset;
		User::LeaveIfError(lex.Val(offset));
		expectedOffsetsList.Append(offset);
		}
	
	//compares the expected offsets for the numeric ids with the actual retrieved offsets
	TESTL(expectedOffsetsList.Count() == offsets.Count());
	for (TInt x = 0; x < expectedOffsetsList.Count(); x++)
		{
		INFO_PRINTF2(_L("tzid : %d"),tzIds[x]);
		}
		
	for (TInt x = 0; x < expectedOffsetsList.Count(); x++)
		{
		INFO_PRINTF2(_L("actual : %d"),offsets[x]);
		}
	
	for (TInt x = 0; x < expectedOffsetsList.Count(); x++)
		{
		TESTL(expectedOffsetsList[x] == offsets[x]);
		}
	
	CleanupStack::PopAndDestroy(&expectedOffsetsList);
	CleanupStack::PopAndDestroy(&expectedOffsetList);
	CleanupStack::PopAndDestroy(&offsets);
	CleanupStack::PopAndDestroy(&tz);
	CleanupStack::PopAndDestroy(&tzIds);
	CleanupStack::PopAndDestroy(&numericIdsList);
	}
Ejemplo n.º 4
0
/** Soak/OOM tests for setting and getting time zones and testing of TimeZoneNameID api
*/
void CTestTZServer::OOMSetCurrentTimeZoneL()
	{
	_LIT8(KEuropeLondon, "Europe/London");
	CTzId* zoneId = CTzId::NewL(KEuropeLondon);
	
	CleanupStack::PushL(zoneId);
	
	_LIT8(KPacificPortMoresby, "Pacific/Port_Moresby");
	CTzId* zoneId1 = CTzId::NewL(KPacificPortMoresby);
	
	CleanupStack::PushL(zoneId1);
	
	RTz tz;
	CleanupClosePushL(tz);
	User::LeaveIfError(tz.Connect());

	TInt i = 0;

	for (i = 0; i < KRepeatApiNumber; i++)
		{
		TRAPD(err,tz.SetTimeZoneL(*zoneId));	
		TESTL(err == KErrNone);
		}
		
	
	for (i = 0; i < KRepeatApiNumber; i++)
		{
		TRAPD(err,tz.SetTimeZoneL(*zoneId1));	
		TESTL(err == KErrNone);
		}
	
	CTzId* tzId = NULL;
	
	iFailAt = 1;
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		TRAPD(err5,tzId = tz.GetTimeZoneIdL());
		
		if ( err5 == KErrNone )
			{
			TESTL(tzId != NULL);
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of GetTimeZoneIdL()) Api is done"));
			break;
			}
				
		if ( ErrorProcess( err5) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}	
		}	

	CleanupStack::PopAndDestroy(&tz);
	CleanupStack::PopAndDestroy(zoneId1);
	CleanupStack::PopAndDestroy(zoneId);
	}
Ejemplo n.º 5
0
/** Performs time conversions (in OOM conditions) to local/universal times either using system or specified time zone
*/
void CTestTZServer::OOMTimeConversionsL()
	{
	CActiveScheduler* scheduler;
	scheduler = new CActiveScheduler();
	CleanupStack::PushL(scheduler);  
	CActiveScheduler::Install(scheduler);
		
	_LIT8(KEuropeLondon, "Europe/London");
	CTzId* zoneId = CTzId::NewL(KEuropeLondon);
	
	CleanupStack::PushL(zoneId);

	RTz tz;
	CTzConverter* timeConverter = NULL;
	CleanupClosePushL(tz);
	User::LeaveIfError(tz.Connect());
	
	TRAPD(err, timeConverter = CTzConverter::NewL(tz));
	TESTL( err == KErrNone );
	
	CleanupStack::PushL(timeConverter);	
	
	TPtrC	ptrSystemTime;
	TESTL(GetStringFromConfig(ConfigSection(), KTime, ptrSystemTime));
	TTime	time(ptrSystemTime);
	
	iFailAt = 1;
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		TInt err = timeConverter->ConvertToLocalTime(time);
		 
		if ( err == KErrNone )
			{
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of ConvertToLocalTime Api (using current time zone) is done"));
			break;
			}
				
		if ( ErrorProcess(err) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}
		}
		
	iFailAt = 1;
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		TInt err = timeConverter->ConvertToLocalTime(time, *zoneId);
		 
		if ( err == KErrNone )
			{
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of ConvertToLocalTime Api (specifiying time zone) is done"));
			break;
			}
				
		if ( ErrorProcess(err) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}
		}	
		
	iFailAt = 1;
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		TInt err = timeConverter->ConvertToUniversalTime(time);
		 
		if ( err == KErrNone )
			{
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of ConvertToUniversalTime Api (using current time zone) is done"));
			break;
			}
				
		if ( ErrorProcess(err) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}
		}	
		
	iFailAt = 1;
	for ( ;; )
		{
		StartHeapCheck(iFailAt);
		TInt err = timeConverter->ConvertToUniversalTime(time, *zoneId);
		 
		if ( err == KErrNone )
			{
			__UHEAP_RESET;
			INFO_PRINTF1(_L("OOM testing of ConvertToUniversalTime (specifiying time zone) Api is done"));
			break;
			}
				
		if ( ErrorProcess(err) )
			{
			EndHeapCheck();
			}
		else
			{
			break;
			}
		}	
		
	CleanupStack::PopAndDestroy(timeConverter);
	CleanupStack::PopAndDestroy(&tz);
	CleanupStack::PopAndDestroy(zoneId);
	CleanupStack::PopAndDestroy(scheduler);
	
	CActiveScheduler::Install(NULL);
	}
Ejemplo n.º 6
0
int SpiderThread::Run(void *param)
{
	HANDLE		httpNotifyEvent[MAX_SPIDER_THREAD+1];
	int waitR=0;
	CMyAsyncHttp::HTTP_STATE state;
	int idleHttpCount=0;
	bool	exit=false;

	m_InterfaceConfig.Lock();
	for(int i=0;i<m_HttpCount;i++)
	{
		httpNotifyEvent[i]=m_Http[i].m_FinishNotify;
		m_Http[i].SetMark(false);
	}
	httpNotifyEvent[i]=m_EndEvent;
	
	UrlInfo*	url=m_MassMem_UrlInfo.AllocMem();
	url->iUrl	=(char*)param;
	
	m_UrlList.push_back(url);
	
	m_SameRegex=(m_UrlRegex==HTTP_REGEX);

	AddHashMap(CUrl::GetUrlHost(url->iUrl),url->iUrl);
	
	while(1)
	{
		idleHttpCount	=0;
		for(int i=0;i<m_HttpCount;i++)
		{
			//检查退出指令
			if(WaitEvent(m_EndEvent,0)==0)
			{
				exit	=true;
				break;
			}
			//判断当前连接是否空闲
			if(m_Http[i].IsIdle())
			{
				state	=m_Http[i].GetHttpState();
				if(state==CMyAsyncHttp::HTTP_FINISH&&m_Http[i].GetCurrentUrl()!="")
				{
					//http请求正确
					int state=m_Http[i].GetStatusCode();
					if(state<400)
					{
						//服务器返回正常
						if(state<300)
							AnalysisData(&m_Http[i]);
						else
							RelocateUrl(&m_Http[i]);
					}
					else
					{
						ErrorProcess(&m_Http[i]);
					}
					m_Http[i].SetMark(true);
				}
				else if(state==CMyAsyncHttp::HTTP_TIMEOUT||state==CMyAsyncHttp::HTTP_STOP)
				{
					//http请求超时
					ErrorProcess(&m_Http[i]);
					m_Http[i].SetMark(true);
				}
				
				if(GetNextUrl())
				{
					m_Http[i].SetParentUrl(m_CurrentUrl->iParentUrl);
					m_Http[i].Get(m_CurrentUrl->iUrl.GetBuffer());

					m_MassMem_UrlInfo.FreeMem(m_CurrentUrl);
					m_Http[i].SetMark(false);

printf("url count:%d\n",m_MassMem_UrlInfo.GetAllocCount());
				}
				else
				{
					idleHttpCount	=0;
					for(int i=0;i<m_HttpCount;i++)
					{
						if(m_Http[i].GetMark())idleHttpCount++;
					}
					if(idleHttpCount==m_HttpCount)
					{
						exit	=true;
						break;
					}
				}
			}
		}

		if(exit)break;
		
		waitR=::WaitForMultipleObjects(m_HttpCount+1,httpNotifyEvent,false,-1);
		
		if(waitR==m_HttpCount)
			break;
	}
	
	m_InterfaceConfig.m_SpiderFinish->OnFinish();
	ClearUrlList();
	return 1;
}