核心模板架构
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include "renderive/frame_control/Frame_Control.hpp"
|
||||
struct Frame_Control_Base_Test_Frame {};
|
||||
using Frame_Control_Base_Test_Strategy = Low_Latency_Strategy<Frame_Control_Base_Test_Frame>;
|
||||
TEST(frame_control_strategy_base_test, publishes_cached_state_only_on_swap) {
|
||||
Frame_Control_Base_Test_Strategy strategy;
|
||||
strategy.set_frequency_hz(120.0);
|
||||
{
|
||||
auto frame = strategy.acquire_painter();
|
||||
ASSERT_TRUE(frame);
|
||||
}
|
||||
{
|
||||
auto frame = strategy.acquire_renderer();
|
||||
ASSERT_TRUE(frame);
|
||||
}
|
||||
EXPECT_DOUBLE_EQ(strategy.state().frequency_hz, 120.0);
|
||||
EXPECT_DOUBLE_EQ(strategy.frequency_hz(), 60.0);
|
||||
strategy.swap();
|
||||
EXPECT_DOUBLE_EQ(strategy.frequency_hz(), 120.0);
|
||||
EXPECT_EQ(strategy.next_refresh_interval_ns(), strategy.state().next_refresh_interval_ns);
|
||||
}
|
||||
TEST(frame_control_strategy_base_test, manual_and_flow_publish_invalid_frequency) {
|
||||
Manual_Refresh_Strategy<Frame_Control_Base_Test_Frame> manual;
|
||||
Flow_Refresh_Strategy<Frame_Control_Base_Test_Frame> flow;
|
||||
manual.swap();
|
||||
flow.swap();
|
||||
EXPECT_TRUE(std::isnan(manual.frequency_hz()));
|
||||
EXPECT_TRUE(std::isnan(flow.frequency_hz()));
|
||||
EXPECT_EQ(manual.next_refresh_interval_ns(), 0);
|
||||
EXPECT_EQ(flow.next_refresh_interval_ns(), 0);
|
||||
}
|
||||
Reference in New Issue
Block a user