2014-02-28 12:23:51 +01:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2017-01-03 15:18:06 +01:00
|
|
|
#include <data/Clump.hpp>
|
2016-09-09 22:13:22 +02:00
|
|
|
#include <objects/VehicleObject.hpp>
|
2017-10-26 03:51:24 +02:00
|
|
|
#include "test_Globals.hpp"
|
2014-02-28 12:23:51 +01:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(VehicleTests)
|
|
|
|
|
2016-06-16 22:11:55 +02:00
|
|
|
#if RW_TEST_WITH_DATA
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_create_vehicle) {
|
|
|
|
VehicleObject* vehicle =
|
2018-02-06 20:47:31 +01:00
|
|
|
Global::get().e->createVehicle(90u, glm::vec3(), glm::quat{1.0f,0.0f,0.0f,0.0f});
|
2014-02-28 12:23:51 +01:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
2014-02-28 12:23:51 +01:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_REQUIRE(vehicle->info != nullptr);
|
2016-09-11 03:58:00 +02:00
|
|
|
BOOST_REQUIRE(vehicle->getVehicle() != nullptr);
|
2014-02-28 12:23:51 +01:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
// Hardcoded values for the moment
|
2016-09-11 03:58:00 +02:00
|
|
|
BOOST_CHECK_EQUAL(vehicle->getVehicle()->vehicletype_,
|
|
|
|
VehicleModelInfo::CAR);
|
2014-02-28 12:23:51 +01:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_CHECK_EQUAL(vehicle->info->wheels.size(), 4);
|
2014-02-28 12:23:51 +01:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_CHECK_EQUAL(vehicle->info->seats.size(), 4);
|
2014-05-29 12:12:40 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
Global::get().e->destroyObject(vehicle);
|
2014-02-28 12:23:51 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(vehicle_parts) {
|
|
|
|
VehicleObject* vehicle =
|
2018-02-06 20:47:31 +01:00
|
|
|
Global::get().e->createVehicle(90u, glm::vec3(), glm::quat{1.0f,0.0f,0.0f,0.0f});
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
2016-09-11 21:04:07 +02:00
|
|
|
BOOST_REQUIRE(vehicle->getModel() != nullptr);
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
VehicleObject::Part* part = vehicle->getPart("bonnet_dummy");
|
|
|
|
|
|
|
|
BOOST_REQUIRE(part != nullptr);
|
|
|
|
|
|
|
|
BOOST_REQUIRE(part->normal != nullptr);
|
|
|
|
BOOST_REQUIRE(part->damaged != nullptr);
|
2014-03-01 05:12:35 +01:00
|
|
|
|
2017-01-08 02:36:08 +01:00
|
|
|
BOOST_REQUIRE(part->normal->getFrame());
|
|
|
|
BOOST_REQUIRE(part->damaged->getFrame());
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(part->normal->getFrame()->getName(), "bonnet_hi_ok");
|
|
|
|
BOOST_CHECK_EQUAL(part->damaged->getFrame()->getName(), "bonnet_hi_dam");
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
Global::get().e->destroyObject(vehicle);
|
2014-03-01 05:12:35 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(vehicle_part_vis) {
|
|
|
|
VehicleObject* vehicle =
|
2018-02-06 20:47:31 +01:00
|
|
|
Global::get().e->createVehicle(90u, glm::vec3(), glm::quat{1.0f,0.0f,0.0f,0.0f});
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
2016-09-11 21:04:07 +02:00
|
|
|
BOOST_REQUIRE(vehicle->getModel() != nullptr);
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
VehicleObject::Part* bonnetpart = vehicle->getPart("bonnet_dummy");
|
2014-05-29 12:12:40 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
vehicle->setPartState(bonnetpart, VehicleObject::DAM);
|
2014-05-29 12:12:40 +02:00
|
|
|
|
2017-01-08 02:36:08 +01:00
|
|
|
BOOST_CHECK((bonnetpart->normal->getFlags() & Atomic::ATOMIC_RENDER) == 0);
|
|
|
|
BOOST_CHECK((bonnetpart->damaged->getFlags() & Atomic::ATOMIC_RENDER) != 0);
|
2014-05-29 12:12:40 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
vehicle->setPartState(bonnetpart, VehicleObject::OK);
|
2014-05-29 12:12:40 +02:00
|
|
|
|
2017-01-08 02:36:08 +01:00
|
|
|
BOOST_CHECK((bonnetpart->normal->getFlags() & Atomic::ATOMIC_RENDER) != 0);
|
|
|
|
BOOST_CHECK((bonnetpart->damaged->getFlags() & Atomic::ATOMIC_RENDER) == 0);
|
2014-05-29 12:12:40 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
Global::get().e->destroyObject(vehicle);
|
2014-05-29 12:12:40 +02:00
|
|
|
}
|
2014-06-20 01:47:13 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_door_position) {
|
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(
|
2018-02-06 20:47:31 +01:00
|
|
|
90u, glm::vec3(10.f, 0.f, 0.f), glm::quat{1.0f,0.0f,0.0f,0.0f});
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle->info != nullptr);
|
2016-09-11 03:58:00 +02:00
|
|
|
BOOST_REQUIRE(vehicle->getVehicle() != nullptr);
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
BOOST_CHECK(vehicle->getSeatEntryPositionWorld(0).x > 5.f);
|
|
|
|
|
|
|
|
Global::get().e->destroyObject(vehicle);
|
2014-12-14 21:45:58 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_hinges) {
|
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(
|
2018-02-06 20:47:31 +01:00
|
|
|
90u, glm::vec3(10.f, 0.f, 0.f), glm::quat{1.0f,0.0f,0.0f,0.0f});
|
2016-09-09 22:13:22 +02: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);
|
|
|
|
|
|
|
|
Global::get().e->destroyObject(vehicle);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_open_part) {
|
|
|
|
VehicleObject* vehicle = Global::get().e->createVehicle(
|
2018-02-06 20:47:31 +01:00
|
|
|
90u, glm::vec3(10.f, 0.f, 0.f), glm::quat{1.0f,0.0f,0.0f,0.0f});
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
BOOST_REQUIRE(vehicle != nullptr);
|
|
|
|
|
|
|
|
VehicleObject::Part* part = vehicle->getPart("door_lf_dummy");
|
|
|
|
|
|
|
|
BOOST_REQUIRE(part != nullptr);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(part->body, nullptr);
|
|
|
|
|
|
|
|
vehicle->setPartLocked(part, true);
|
|
|
|
vehicle->setPartTarget(part, true, 1.f);
|
|
|
|
|
|
|
|
/// @todo a reasonable test
|
|
|
|
|
|
|
|
Global::get().e->destroyObject(vehicle);
|
2014-06-20 01:47:13 +02:00
|
|
|
}
|
2016-06-16 22:11:55 +02:00
|
|
|
#endif
|
2014-06-20 01:47:13 +02:00
|
|
|
|
2014-02-28 12:23:51 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|