| 8 | { |
| 9 | |
| 10 | TEST_F(RadiantTest, SetCameraPositionAndAngles) |
| 11 | { |
| 12 | // Assume that we don't have any camera at first |
| 13 | bool exceptionThrown = false; |
| 14 | |
| 15 | try |
| 16 | { |
| 17 | GlobalCameraManager().getActiveView(); |
| 18 | } |
| 19 | catch (const std::runtime_error&) |
| 20 | { |
| 21 | exceptionThrown = true; |
| 22 | } |
| 23 | |
| 24 | ASSERT_TRUE(exceptionThrown); |
| 25 | |
| 26 | render::View view; |
| 27 | auto allocatedCam = GlobalCameraManager().createCamera(view, [](bool) {}); |
| 28 | |
| 29 | // We should be able to get an active camera now |
| 30 | exceptionThrown = false; |
| 31 | try |
| 32 | { |
| 33 | auto& camera = GlobalCameraManager().getActiveView(); |
| 34 | auto oldPosition = camera.getCameraOrigin(); |
| 35 | auto oldAngles = camera.getCameraAngles(); |
| 36 | |
| 37 | // Run the command, and compare the camera's angles |
| 38 | GlobalCommandSystem().executeCommand("SetActiveCameraPosition", cmd::Argument(oldPosition + Vector3(50,50,50))); |
| 39 | |
| 40 | auto newPosition = camera.getCameraOrigin(); |
| 41 | ASSERT_TRUE(oldPosition != newPosition); // position changed |
| 42 | ASSERT_TRUE(camera.getCameraAngles() == oldAngles); // angles unchanged |
| 43 | |
| 44 | GlobalCommandSystem().executeCommand("SetActiveCameraAngles", cmd::Argument(oldAngles + Vector3(10,10,10))); |
| 45 | |
| 46 | ASSERT_TRUE(camera.getCameraOrigin() == newPosition); // position unchanged |
| 47 | ASSERT_TRUE(camera.getCameraAngles() != oldAngles); // angles changed |
| 48 | } |
| 49 | catch (const std::runtime_error&) |
| 50 | { |
| 51 | exceptionThrown = true; |
| 52 | } |
| 53 | |
| 54 | ASSERT_TRUE(exceptionThrown == false); |
| 55 | |
| 56 | GlobalCameraManager().destroyCamera(allocatedCam); |
| 57 | } |
| 58 | |
| 59 | } |
nothing calls this directly
no test coverage detected