Ejemplo n.º 1
0
TEST(UAVObjManager, bind_connect_disconneect)
{
	boost::system_time t;
	AccessoryDesired::DataFields data;
	AccessoryDesired *obj1 = AccessoryDesired::GetInstance(objMngr, 0);

	ASSERT_NE(obj1, (void*)NULL);

	bind_updated = 0;
	obj1->objectUpdated.connect(boost::bind(bind_objUpdated, _1));

	data = obj1->getData();
	data.AccessoryVal++;
	obj1->setData(data);

	t = boost::get_system_time() +
		boost::posix_time::milliseconds(100);
	mutex.timed_lock(t);

	EXPECT_EQ(bind_updated, 1);

	obj1->objectUpdated.disconnect(boost::bind(bind_objUpdated, _1));

	data = obj1->getData();
	data.AccessoryVal++;
	obj1->setData(data);

	t = boost::get_system_time() +
		boost::posix_time::milliseconds(100);
	mutex.timed_lock(t);

	EXPECT_EQ(bind_updated, 1);
}
Ejemplo n.º 2
0
TEST(UAVObjManager, registerTwo)
{
	boost::system_time t;
	objMngr = new UAVObjectManager();

	newobj = 0;
	newinst = 0;

	objMngr->newObject.connect(newObject);
	objMngr->newInstance.connect(newInstance);

	AccessoryDesired *obj1 = new AccessoryDesired();
	obj1->objectUpdated.connect(objUpdated);
	obj1->objectUpdatedAuto.connect(objUpdatedAuto);
	obj1->objectUpdatedManual.connect(objUpdatedManual);
	obj1->updateRequested.connect(updRequested);

	objMngr->registerObject(obj1);

	t = boost::get_system_time() +
		boost::posix_time::milliseconds(100);
	mutex.timed_lock(t);
	EXPECT_GT(newobj, 0);

	AccessoryDesired *obj2 = new AccessoryDesired();
	obj2->objectUpdated.connect(objUpdated);
	obj2->objectUpdatedAuto.connect(objUpdatedAuto);
	obj2->objectUpdatedManual.connect(objUpdatedManual);
	obj2->updateRequested.connect(updRequested);

	objMngr->registerObject(obj2);

	t = boost::get_system_time() +
		boost::posix_time::milliseconds(100);
	mutex.timed_lock(t);
	EXPECT_GT(newinst, 0);
}