TEST(TimeManagerTest, testTimeoutNoParam) {
	TimeManager time;
	timeManagerTestCallback.callbackNoParamCalled = false;
	time.setTimeout(1, &timeManagerTestCallback,
			&TimeManagerTestCallback::timeoutNoParamCallback);
	time.update(1);
	ASSERT_TRUE(timeManagerTestCallback.callbackNoParamCalled);
}
TEST(TimeManagerTest, testTimeoutWithParam) {
	TimeManager time;
	timeManagerTestCallback.callbackWithParamCalled = false;
	float param = 5.50f;
	time.setTimeout(1, &timeManagerTestCallback,
			&TimeManagerTestCallback::timeoutWithParamCallback, (void*) &param);
	time.update(1);
	ASSERT_TRUE(timeManagerTestCallback.callbackWithParamCalled);
	ASSERT_EQ(timeManagerTestCallback.callbackParamValue, param);
}
Example #3
0
void testManagers()
{	
	/*
	struct MyObject;
	struct MyStorage: public IDPair<MyStorage,MyObject>::Store
	{
	}storage;
	struct MyObject: public IDPair<MyStorage,MyObject>::Stored
	{
		MyObject(MyStorage *manager,const char *n)
			:Stored(manager),hello(n)
		{}
		std::string hello;
	};
	new MyObject(&storage,"object1");
	new MyObject(&storage,"object2");
	new MyObject(&storage,"object3");
	new MyObject(&storage,"object4");*/
	TimeManager manager;
	struct TestEvent : public TimeManager::Action
	{
	public:
		std::string eventMsg;
		TestEvent(const std::string &str):eventMsg(str){}
		virtual void Execute()
		{
			printf("TestEvent::Execute(%s)\n",eventMsg.c_str());
		}
	};
	manager.add(new TestEvent("Event 1"), 40);
	manager.add(new TestEvent("Event 2"), 60);
	manager.add(new TestEvent("Event 3"), 20);
	manager.add(new TestEvent("Event 4"), 50);
	for(int i = 0; i < 8; i++)
		manager.update(5);

	manager.add(new TestEvent("Event 5"), 20);
	manager.add(new TestEvent("Event 6"), 30);	
	for(int i = 0; i < 30; i++)
		manager.update(5);
	int w = 0;
}