Add test loop in main.cpp
This commit is contained in:
parent
bb1e8ee3e1
commit
513fc61d34
|
@ -30,5 +30,6 @@ run_tests:
|
||||||
- Xvfb :99 -screen 0 1024x768x24 &
|
- Xvfb :99 -screen 0 1024x768x24 &
|
||||||
- sleep 5
|
- sleep 5
|
||||||
- export DISPLAY=:99
|
- export DISPLAY=:99
|
||||||
|
- export TEST_MODE=1
|
||||||
- cd build
|
- cd build
|
||||||
- timeout 30s ./TerraVisor
|
- ./TerraVisor
|
||||||
|
|
|
@ -107,7 +107,7 @@ void MainLoop(GLFWwindow* window, Scene& scene) {
|
||||||
auto frame_duration = frame_end - frame_start;
|
auto frame_duration = frame_end - frame_start;
|
||||||
|
|
||||||
if (frame_duration < kFrameDuration) {
|
if (frame_duration < kFrameDuration) {
|
||||||
std::this_thread::sleep_for(kFrameDuration - frame_duration);
|
std::this_thread::sleep_for(kFrameDuration - frame_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto current_frame_time = std::chrono::high_resolution_clock::now();
|
auto current_frame_time = std::chrono::high_resolution_clock::now();
|
||||||
|
@ -117,6 +117,21 @@ void MainLoop(GLFWwindow* window, Scene& scene) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestLoop(GLFWwindow* window, Scene& scene) {
|
||||||
|
auto start = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
while (!glfwWindowShouldClose(window)) {
|
||||||
|
scene.Idle();
|
||||||
|
scene.Display(window);
|
||||||
|
glfwPollEvents();
|
||||||
|
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
if(std::chrono::duration_cast<std::chrono::seconds>(now - start).count() > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
@ -132,7 +147,13 @@ int main() {
|
||||||
scene.Init();
|
scene.Init();
|
||||||
InitializeImGui(window);
|
InitializeImGui(window);
|
||||||
|
|
||||||
MainLoop(window, scene);
|
// Check if we're in test mode
|
||||||
|
const char* testEnv = std::getenv("TEST_MODE");
|
||||||
|
if(testEnv) {
|
||||||
|
TestLoop(window, scene);
|
||||||
|
} else {
|
||||||
|
MainLoop(window, scene);
|
||||||
|
}
|
||||||
|
|
||||||
CleanupImGui();
|
CleanupImGui();
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
|
|
Loading…
Reference in New Issue