2014-02-28 12:23:51 +01:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include "test_globals.hpp"
|
2014-06-06 16:22:26 +02:00
|
|
|
#include <objects/VehicleObject.hpp>
|
2014-03-01 05:12:35 +01:00
|
|
|
#include <render/Model.hpp>
|
2014-12-11 18:48:47 +01:00
|
|
|
#include <data/Skeleton.hpp>
|
2014-02-28 12:23:51 +01:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(VehicleTests)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_create_vehicle)
|
|
|
|
{
|
2014-06-06 16:22:26 +02:00
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
|
2014-02-28 12:23:51 +01:00
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle->info != nullptr);
|
|
|
|
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
|
|
|
|
|
|
|
// Hardcoded values for the moment
|
|
|
|
BOOST_CHECK_EQUAL(vehicle->vehicle->type, VehicleData::CAR);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(vehicle->info->wheels.size(), 4);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(vehicle->info->seats.size(), 4);
|
2014-05-29 12:12:40 +02:00
|
|
|
|
|
|
|
Global::get().e->destroyObject(vehicle);
|
2014-02-28 12:23:51 +01:00
|
|
|
}
|
|
|
|
|
2014-12-14 02:32:00 +01:00
|
|
|
BOOST_AUTO_TEST_CASE(vehicle_parts)
|
2014-03-01 05:12:35 +01:00
|
|
|
{
|
2014-06-06 16:22:26 +02:00
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
|
2014-03-01 05:12:35 +01:00
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
|
|
|
BOOST_REQUIRE(vehicle->model != nullptr);
|
2014-12-14 02:32:00 +01:00
|
|
|
|
|
|
|
VehicleObject::Part* part = vehicle->getPart("bonnet_dummy");
|
|
|
|
|
|
|
|
BOOST_REQUIRE( part != nullptr );
|
|
|
|
|
|
|
|
BOOST_REQUIRE( part->normal != nullptr );
|
|
|
|
BOOST_REQUIRE( part->damaged != nullptr );
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL( part->normal->getName(), "bonnet_hi_ok");
|
|
|
|
BOOST_CHECK_EQUAL( part->damaged->getName(), "bonnet_hi_dam");
|
|
|
|
|
|
|
|
Global::get().e->destroyObject(vehicle);
|
|
|
|
}
|
2014-03-01 05:12:35 +01:00
|
|
|
|
2014-12-14 02:32:00 +01:00
|
|
|
BOOST_AUTO_TEST_CASE(vehicle_part_vis)
|
|
|
|
{
|
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
|
2014-03-01 05:12:35 +01:00
|
|
|
|
2014-12-14 02:32:00 +01:00
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
|
|
|
BOOST_REQUIRE(vehicle->model != nullptr);
|
|
|
|
|
|
|
|
VehicleObject::Part* bonnetpart = vehicle->getPart("bonnet_dummy");
|
|
|
|
auto skel = vehicle->skeleton;
|
|
|
|
|
|
|
|
vehicle->setPartState(bonnetpart, VehicleObject::DAM);
|
|
|
|
|
|
|
|
BOOST_CHECK(!skel->getData(bonnetpart->normal->getIndex()).enabled );
|
|
|
|
BOOST_CHECK( skel->getData(bonnetpart->damaged->getIndex()).enabled );
|
|
|
|
|
|
|
|
vehicle->setPartState(bonnetpart, VehicleObject::OK);
|
|
|
|
|
|
|
|
BOOST_CHECK( skel->getData(bonnetpart->normal->getIndex()).enabled );
|
|
|
|
BOOST_CHECK(!skel->getData(bonnetpart->damaged->getIndex()).enabled );
|
2014-03-01 05:12:35 +01:00
|
|
|
|
2014-05-29 12:12:40 +02:00
|
|
|
Global::get().e->destroyObject(vehicle);
|
2014-03-01 05:12:35 +01:00
|
|
|
}
|
|
|
|
|
2014-05-29 12:12:40 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_door_position)
|
|
|
|
{
|
2014-06-06 16:22:26 +02:00
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
|
2014-05-29 12:12:40 +02:00
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle->info != nullptr);
|
|
|
|
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
|
|
|
|
|
|
|
BOOST_CHECK( vehicle->getSeatEntryPosition(0).x > 5.f );
|
|
|
|
|
|
|
|
|
|
|
|
Global::get().e->destroyObject(vehicle);
|
|
|
|
}
|
2014-06-20 01:47:13 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_hinges)
|
|
|
|
{
|
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
|
2014-12-14 02:32:00 +01:00
|
|
|
|
|
|
|
BOOST_REQUIRE( vehicle != nullptr );
|
|
|
|
|
|
|
|
VehicleObject::Part* part = vehicle->getPart("door_lf_dummy");
|
|
|
|
|
|
|
|
BOOST_REQUIRE( part != nullptr );
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL( part->constraint, nullptr );
|
|
|
|
BOOST_CHECK_EQUAL( part->body, nullptr );
|
|
|
|
|
|
|
|
vehicle->setPartLocked(part, false);
|
|
|
|
|
|
|
|
BOOST_CHECK_NE( part->body, nullptr );
|
|
|
|
BOOST_CHECK_NE( part->constraint, nullptr );
|
|
|
|
|
|
|
|
vehicle->setPartLocked(part, true);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL( part->constraint, nullptr );
|
|
|
|
BOOST_CHECK_EQUAL( part->body, nullptr );
|
2014-06-20 01:47:13 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 12:23:51 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|
|
|
|
|