82 lines
2.8 KiB
C++
82 lines
2.8 KiB
C++
#include <mln/renderer/particle_viewport_reseed.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
using namespace mln;
|
|
|
|
TEST(ParticleViewportReseed, ZoomOutBeyondEpsilonReseedsOnce) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(10.0);
|
|
|
|
const auto decision = gesture.finish(8.0, true);
|
|
EXPECT_EQ(decision.action, ParticleViewportReseedAction::Reseed);
|
|
EXPECT_DOUBLE_EQ(decision.startZoom, 10.0);
|
|
EXPECT_DOUBLE_EQ(decision.endZoom, 8.0);
|
|
EXPECT_FALSE(gesture.isActive());
|
|
EXPECT_EQ(gesture.finish(7.0, true).action, ParticleViewportReseedAction::None);
|
|
}
|
|
|
|
TEST(ParticleViewportReseed, ZoomInDoesNotReseed) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(8.0);
|
|
|
|
EXPECT_EQ(gesture.finish(10.0, true).action, ParticleViewportReseedAction::None);
|
|
EXPECT_FALSE(gesture.isActive());
|
|
}
|
|
|
|
TEST(ParticleViewportReseed, PanDoesNotReseed) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(8.0);
|
|
|
|
EXPECT_EQ(gesture.finish(8.0, true).action, ParticleViewportReseedAction::None);
|
|
}
|
|
|
|
TEST(ParticleViewportReseed, RotateOrPitchWithoutZoomDecreaseDoesNotReseed) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(8.0);
|
|
|
|
EXPECT_EQ(gesture.finish(8.01, true).action, ParticleViewportReseedAction::None);
|
|
}
|
|
|
|
TEST(ParticleViewportReseed, ZoomJitterWithinEpsilonDoesNotReseed) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(8.0);
|
|
|
|
EXPECT_EQ(gesture.finish(8.0 - ParticleViewportReseedZoomEpsilon, true).action,
|
|
ParticleViewportReseedAction::None);
|
|
}
|
|
|
|
TEST(ParticleViewportReseed, InvalidDomainConsumesZoomOutRequest) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(10.0);
|
|
|
|
const auto decision = gesture.finish(8.0, false);
|
|
EXPECT_EQ(decision.action, ParticleViewportReseedAction::SkipInvalidDomain);
|
|
EXPECT_FALSE(gesture.isActive());
|
|
EXPECT_EQ(gesture.finish(7.0, true).action, ParticleViewportReseedAction::None);
|
|
}
|
|
|
|
TEST(ParticleViewportReseed, ContinuousInvalidationKeepsFirstStartZoom) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(10.0);
|
|
gesture.begin(9.0);
|
|
gesture.begin(8.0);
|
|
|
|
EXPECT_DOUBLE_EQ(gesture.getStartZoom(), 10.0);
|
|
const auto decision = gesture.finish(7.0, true);
|
|
EXPECT_DOUBLE_EQ(decision.startZoom, 10.0);
|
|
EXPECT_EQ(decision.action, ParticleViewportReseedAction::Reseed);
|
|
}
|
|
|
|
TEST(ParticleViewportReseed, NextGestureRefreshesStartZoom) {
|
|
ParticleViewportReseedGesture gesture;
|
|
gesture.begin(10.0);
|
|
EXPECT_EQ(gesture.finish(8.0, true).action, ParticleViewportReseedAction::Reseed);
|
|
|
|
gesture.begin(6.0);
|
|
EXPECT_DOUBLE_EQ(gesture.getStartZoom(), 6.0);
|
|
const auto decision = gesture.finish(5.0, true);
|
|
EXPECT_DOUBLE_EQ(decision.startZoom, 6.0);
|
|
EXPECT_EQ(decision.action, ParticleViewportReseedAction::Reseed);
|
|
}
|