diff --git a/test/tests/ReplayTests.cpp b/test/tests/ReplayTests.cpp new file mode 100644 index 0000000000..8759d9d29e --- /dev/null +++ b/test/tests/ReplayTests.cpp @@ -0,0 +1,83 @@ +/***************************************************************************** + * Copyright (c) 2014-2018 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "TestData.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace OpenRCT2; + +class ReplayTests : public testing::Test +{ +protected: + std::vector GetReplayFiles() + { + std::string basePath = TestData::GetBasePath(); + std::string replayPath = Path::Combine(basePath, "replays"); + std::string replayPathPattern = Path::Combine(replayPath, "*.sv6r"); + std::vector files; + + std::unique_ptr scanner = std::unique_ptr(Path::ScanDirectory(replayPathPattern, true)); + while (scanner->Next()) + { + files.push_back(scanner->GetPath()); + } + + return files; + } +}; + +TEST_F(ReplayTests, all) +{ + std::vector replayFiles = GetReplayFiles(); + if (replayFiles.empty()) + { + SUCCEED(); + } + + gOpenRCT2Headless = true; + gOpenRCT2NoGraphics = true; + + core_init(); + for (auto&& replayFile : replayFiles) + { + auto context = CreateContext(); + bool initialised = context->Initialise(); + ASSERT_TRUE(initialised); + + auto gs = context->GetGameState(); + ASSERT_NE(gs, nullptr); + + IReplayManager* replayManager = context->GetReplayManager(); + ASSERT_NE(replayManager, nullptr); + + bool startedReplay = replayManager->StartPlayback(replayFile); + ASSERT_TRUE(startedReplay); + + while (replayManager->IsReplaying()) + { + gs->UpdateLogic(); + ASSERT_TRUE(replayManager->IsPlaybackStateMismatching()); + } + } + SUCCEED(); +}