void
Ut_AlertTonePreviewTests::alerttonepreviewfname()
{
      MApplicationWindow aw;
      AlertTonePreview  atp("/usr/share/sounds/ring-tones/Lucid dreaming.aac");
      atp.gstInit();
      QCOMPARE(atp.fname(), QString( "/usr/share/sounds/ring-tones/Lucid dreaming.aac" ));
}
void
Ut_AlertTonePreviewTests::alerttonepreviewProfileToGstVolume()
{
      MApplicationWindow aw;
      AlertTonePreview  atp("/usr/share/sounds/ring-tones/Lucid dreaming.aac");
      atp.gstInit();
      qDebug() << atp.profileToGstVolume();
      double  volume;
      volume = atp.profileToGstVolume();
      QVERIFY ( volume >= 0 && volume <= 1 );
}
void
Ut_AlertTonePreviewTests::alerttonepreviewConstructor ()
{
      MApplicationWindow aw;
      AlertTonePreview  atp("/usr/share/sounds/ring-tones/Lucid dreaming.aac");
      atp.gstInit();

      QVERIFY (atp.m_gstPipeline != 0 );
      QVERIFY (atp.m_gstVolume != 0 );
      QCOMPARE(atp.m_profileVolume.key(), QString( "ringing.alert.volume@general" ));
}
void Scene::renderGameStatistics()
{
	// Show intro
	if( m_fTimer < 3.0f )
	{
		scene->renderFont( 255, 0, 255, 0, 3.0f, GAME_WIDTH / 2.0f, 30.0f, HGETEXT_CENTER, "-=SURVIVAL=-" ); 
	}

	// Show statistics
	std::string atp( "attempts: " );
	atp += std::to_string( attempts ); 
	renderFont( 255, 128, 128, 128, 1.0f, GAME_WIDTH - 140.0f, 10.0f, HGETEXT_LEFT, atp );

	std::string str( "health: ");
	int health = static_cast<int>( objects->getTank( )->getHealth( ) * 100 );
	str += std::to_string( health ); 
	renderFont( 255, 128, 128, 128, 1.0f, GAME_WIDTH - 140.0f, 40.0f, HGETEXT_LEFT, str );

	std::string timer( "timer: "); 
	timer += std::to_string( static_cast<int>(SURVIVAL_TIME) - static_cast<int>(m_fTimer) );
	timer += "s";
	renderFont( 255, 128, 128, 128, 1.0f, GAME_WIDTH - 140.0f, 70.0f, HGETEXT_LEFT, timer );

	std::string bst( "beasts: ") ;
	bst += std::to_string( objects->getDeadBeastQuantity( ) ); 
	renderFont( 255, 128, 128, 128, 1.0f, 10.0f, 10.0f, HGETEXT_LEFT, bst );

	std::string dmn( "daemons: ");
	dmn += std::to_string( objects->getDeadDaemonQuantity( ) ); 
	renderFont( 255, 128, 128, 128, 1.0f, 10.0f, 40.0f, HGETEXT_LEFT, dmn );

	std::string rpt( "reptiles: "); 
	rpt += std::to_string( objects->getDeadReptileQuantity( ) );
	renderFont( 255, 128, 128, 128, 1.0f, 10.0f, 70.0f, HGETEXT_LEFT, rpt );

	std::string blt( "bullets: ");
	blt += std::to_string( Weapon::getBulletsQuantity( ) );
	renderFont( 255, 128, 128, 128, 1.0f, 10.0f, GAME_HEIGHT - 90.0f, HGETEXT_LEFT, blt );

	std::string shl( "shells: ");
	shl += std::to_string( Weapon::getShellsQuantity( ) );
	renderFont( 255, 128, 128, 128, 1.0f, 10.0f, GAME_HEIGHT - 60.0f, HGETEXT_LEFT, shl );

	std::string rct( "rockets: ");
	rct += std::to_string( Weapon::getRocketsQuantity( ) );
	renderFont( 255, 128, 128, 128, 1.0f, 10.0f, GAME_HEIGHT - 30.0f, HGETEXT_LEFT, rct );
}
void
Ut_AlertTonePreviewTests::alerttonepreviewProfileVolumeChanged()
{
      MApplicationWindow aw;
      AlertTonePreview  atp("/usr/share/sounds/ring-tones/Lucid dreaming.aac");
      atp.gstInit();
      double  *  cnt = new double;
      atp.m_profileVolume.set(QVariant(50));
      atp.m_profileVolume.emit_changed();

      g_object_get(G_OBJECT(atp.m_gstVolume), "volume", cnt, NULL);

      QVERIFY (qFuzzyCompare ( (float) *cnt, (float) 0.5 ) );

      atp.m_profileVolume.set(QVariant(90));
      atp.m_profileVolume.emit_changed();

      g_object_get(G_OBJECT(atp.m_gstVolume), "volume", cnt, NULL);
      QVERIFY (qFuzzyCompare ( (float) *cnt, (float) 0.9 ) );
}
Exemple #6
0
//---------------------------------------------------------------------------
//	@function:
//		CMDAccessorTest::PvInitMDAAndLookup
//
//	@doc:
//		Task which initializes a MD accessor and looks up multiple objects through
//		that accessor
//
//---------------------------------------------------------------------------
void *
CMDAccessorTest::PvInitMDAAndLookup
	(
	void * pv
	)
{
	GPOS_ASSERT(NULL != pv);
	
	CMDAccessor::MDCache *pcache = (CMDAccessor::MDCache *) pv;

	CAutoMemoryPool amp;
	IMemoryPool *mp = amp.Pmp();
	CWorkerPoolManager *pwpm = CWorkerPoolManager::WorkerPoolManager();
	
	// task memory pool
	CAutoMemoryPool ampTask;
	IMemoryPool *pmpTask = ampTask.Pmp();
	
	// scope for MD accessor
	{			
		// Setup an MD cache with a file-based provider
		CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
		pmdp->AddRef();
		CMDAccessor mda(mp, pcache, CTestUtils::m_sysidDefault, pmdp);
		
		// task parameters
		SMDCacheTaskParams mdtaskparams(pmpTask, &mda);

		// scope for ATP
		{	
			CAutoTaskProxy atp(mp, pwpm);
	
			CTask *rgPtsk[GPOPT_MDCACHE_LOOKUP_THREADS];
	
			TaskFuncPtr rgPfuncTask[] =
				{
				CMDAccessorTest::PvLookupSingleObj,
				CMDAccessorTest::PvLookupMultipleObj
				};
	
			const ULONG ulNumberOfTaskTypes = GPOS_ARRAY_SIZE(rgPfuncTask);
	
			// create tasks
			for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
			{
				rgPtsk[i] = atp.Create
							(
							rgPfuncTask[i % ulNumberOfTaskTypes],
							&mdtaskparams
							);
	
				GPOS_CHECK_ABORT;
			}
			
			for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
			{	
				atp.Schedule(rgPtsk[i]);
			}
			
			GPOS_CHECK_ABORT;
	
			// wait for completion
			for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
			{
				atp.Wait(rgPtsk[i]);
				GPOS_CHECK_ABORT;
	
			}
		}
	
	}
	
	return NULL;
}
Exemple #7
0
//---------------------------------------------------------------------------
//	@function:
//		CMDAccessorTest::EresUnittest_ConcurrentAccessMultipleMDA
//
//	@doc:
//		Test concurrent access through multiple MD accessors from different threads
//
//---------------------------------------------------------------------------
GPOS_RESULT
CMDAccessorTest::EresUnittest_ConcurrentAccessMultipleMDA()
{
	CAutoMemoryPool amp;
	IMemoryPool *mp = amp.Pmp();
	CWorkerPoolManager *pwpm = CWorkerPoolManager::WorkerPoolManager();

#ifdef GPOS_DEBUG
	BOOL fOld = IWorker::m_enforce_time_slices;
	IWorker::m_enforce_time_slices = false;
#endif

	GPOS_TRY
	{	
		CAutoTaskProxy atp(mp, pwpm);
	
		// create multiple tasks eash of which will init a separate MD accessor and use it to
		// lookup objects from the respective accessor using different threads
		CTask *rgPtsk[GPOPT_MDCACHE_MDAS];
		
		// create tasks
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			rgPtsk[i] = atp.Create
						(
						PvInitMDAAndLookup,
						CMDCache::Pcache()	// task arg
						);
	
			GPOS_CHECK_ABORT;
		}
			
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			atp.Schedule(rgPtsk[i]);
		}
			
		GPOS_CHECK_ABORT;

		// wait for completion
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			atp.Wait(rgPtsk[i]);
			GPOS_CHECK_ABORT;
	
		}
	}
	GPOS_CATCH_EX(ex)
	{
#ifdef GPOS_DEBUG
		IWorker::m_enforce_time_slices = fOld;
#endif

		GPOS_RETHROW(ex);
	}
	GPOS_CATCH_END;
	
#ifdef GPOS_DEBUG
	IWorker::m_enforce_time_slices = fOld;
#endif

	return GPOS_OK;
}
Exemple #8
0
//---------------------------------------------------------------------------
//	@function:
//		CMDAccessorTest::EresUnittest_ConcurrentAccessSingleMDA
//
//	@doc:
//		Test concurrent access through a single MD accessor from different threads
//
//---------------------------------------------------------------------------
GPOS_RESULT
CMDAccessorTest::EresUnittest_ConcurrentAccessSingleMDA()
{
	CAutoMemoryPool amp;
	IMemoryPool *mp = amp.Pmp();
	CWorkerPoolManager *pwpm = CWorkerPoolManager::WorkerPoolManager();
	
	// task memory pool
	CAutoMemoryPool ampTask;
	IMemoryPool *pmpTask = ampTask.Pmp();
	
	// setup a file-based provider
	// Setup an MD cache with a file-based provider
	CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
	pmdp->AddRef();
	CMDAccessor mda(mp, CMDCache::Pcache(), CTestUtils::m_sysidDefault, pmdp);

	// task parameters
	SMDCacheTaskParams mdtaskparams(pmpTask, &mda);

	// scope for ATP
	{
		CAutoTaskProxy atp(mp, pwpm);
	
		CTask *rgPtsk[GPOPT_MDCACHE_LOOKUP_THREADS];
	
		TaskFuncPtr rgPfuncTask[] =
			{
			CMDAccessorTest::PvLookupSingleObj,
			CMDAccessorTest::PvLookupMultipleObj
			};
	
		const ULONG ulNumberOfTaskTypes = GPOS_ARRAY_SIZE(rgPfuncTask);
	
		// create tasks
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			rgPtsk[i] = atp.Create
						(
						rgPfuncTask[i % ulNumberOfTaskTypes],
						&mdtaskparams
						);
	
			GPOS_CHECK_ABORT;
		}
			
		for (ULONG i = 0; i < GPOPT_MDCACHE_LOOKUP_THREADS; i++)
		{
			atp.Schedule(rgPtsk[i]);
		}
			
		GPOS_CHECK_ABORT;

		// wait for completion
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			atp.Wait(rgPtsk[i]);
			GPOS_CHECK_ABORT;
	
		}
	}
	
	return GPOS_OK;
}