Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 888df2c52077
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b210810bb41b
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 21, 2017

  1. Mock for Renderer.

    pleroy committed May 21, 2017
    Copy the full SHA
    a252e9b View commit details
  2. Merge pull request #1393 from pleroy/Mock

    A mock class for Renderer
    pleroy authored May 21, 2017
    Copy the full SHA
    b210810 View commit details
Showing with 97 additions and 0 deletions.
  1. +44 −0 ksp_plugin_test/mock_renderer.cpp
  2. +53 −0 ksp_plugin_test/mock_renderer.hpp
44 changes: 44 additions & 0 deletions ksp_plugin_test/mock_renderer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "mock_renderer.hpp"

#include "physics/mock_dynamic_frame.hpp"

namespace principia {
namespace ksp_plugin {
namespace internal_renderer {

using physics::MockDynamicFrame;

MockCelestial* const sun = new MockCelestial;

MockRenderer::MockRenderer()
: Renderer(sun,
std::make_unique<MockDynamicFrame<Barycentric, Navigation>>()) {}

void MockRenderer::SetPlottingFrame(
not_null<std::unique_ptr<NavigationFrame>> plotting_frame) {
SetPlottingFrameConstRef(*plotting_frame);
plotting_frame.release();
}

not_null<std::unique_ptr<DiscreteTrajectory<World>>>
MockRenderer::RenderBarycentricTrajectoryInWorld(
Instant const& time,
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
Rotation<Barycentric, AliceSun> const& planetarium_rotation) const {
std::unique_ptr<DiscreteTrajectory<World>>
rendered_barycentric_trajectory_in_world;
FillRenderedBarycentricTrajectoryInWorld(
time,
begin,
end,
sun_world_position,
planetarium_rotation,
&rendered_barycentric_trajectory_in_world);
return std::move(rendered_barycentric_trajectory_in_world);
}

} // namespace internal_renderer
} // namespace ksp_plugin
} // namespace principia
53 changes: 53 additions & 0 deletions ksp_plugin_test/mock_renderer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#pragma once

#include "ksp_plugin/renderer.hpp"

#include "gmock/gmock.h"
#include "ksp_plugin_test/mock_celestial.hpp"

namespace principia {
namespace ksp_plugin {
namespace internal_renderer {

class MockRenderer : public Renderer {
public:
MockRenderer();

// NOTE(phl): Needed because gMock wants to copy the unique_ptr<>.
void SetPlottingFrame(
not_null<std::unique_ptr<NavigationFrame>> plotting_frame) override;
MOCK_METHOD1(SetPlottingFrameConstRef,
void(NavigationFrame const& plotting_frame));

MOCK_CONST_METHOD0(GetPlottingFrame, not_null<NavigationFrame const*> ());

not_null<std::unique_ptr<DiscreteTrajectory<World>>>
RenderBarycentricTrajectoryInWorld(
Instant const& time,
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
Rotation<Barycentric, AliceSun> const& planetarium_rotation)
const override;
MOCK_CONST_METHOD6(
FillRenderedBarycentricTrajectoryInWorld,
void(Instant const& time,
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
Rotation<Barycentric, AliceSun> const& planetarium_rotation,
std::unique_ptr<DiscreteTrajectory<World>>*
rendered_barycentric_trajectory_in_world));

MOCK_CONST_METHOD1(
BarycentricToWorldSun,
OrthogonalMap<Barycentric, WorldSun>(
Rotation<Barycentric, AliceSun> const& planetarium_rotation));
};

} // namespace internal_renderer

using internal_renderer::MockRenderer;

} // namespace ksp_plugin
} // namespace principia