Add test loop in main.cpp

This commit is contained in:
Jack Christensen 2024-08-19 10:43:07 -04:00
parent bb1e8ee3e1
commit 513fc61d34
2 changed files with 25 additions and 3 deletions

View File

@ -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

View File

@ -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);
// Check if we're in test mode
const char* testEnv = std::getenv("TEST_MODE");
if(testEnv) {
TestLoop(window, scene);
} else {
MainLoop(window, scene); MainLoop(window, scene);
}
CleanupImGui(); CleanupImGui();
glfwDestroyWindow(window); glfwDestroyWindow(window);