Added test cases for marker_model and marker_manager

This commit is contained in:
AdenKoperczak 2024-10-20 12:37:08 -04:00
parent 2c9a8a33a4
commit 236d7c1e35
7 changed files with 227 additions and 6 deletions

View file

@ -44,6 +44,14 @@ void WaitForInitialization()
}
}
// Only use for test cases
void ResetInitilization()
{
logger_->debug("Application initialization reset");
std::unique_lock lock(initializationMutex_);
initialized_ = false;
}
} // namespace Application
} // namespace main
} // namespace qt

View file

@ -11,6 +11,8 @@ namespace Application
void FinishInitialization();
void WaitForInitialization();
// Only use for test cases
void ResetInitilization();
} // namespace Application
} // namespace main

View file

@ -36,7 +36,7 @@ public:
explicit Impl(MarkerManager* self) : self_ {self} {}
~Impl() { threadPool_.join(); }
std::string markerSettingsPath_ {};
std::string markerSettingsPath_ {""};
std::vector<std::shared_ptr<MarkerRecord>> markerRecords_ {};
MarkerManager* self_;
@ -176,14 +176,13 @@ MarkerManager::Impl::GetMarkerByName(const std::string& name)
MarkerManager::MarkerManager() : p(std::make_unique<Impl>(this))
{
p->InitializeMarkerSettings();
boost::asio::post(p->threadPool_,
[this]()
{
try
{
p->InitializeMarkerSettings();
// Read Marker settings on startup
main::Application::WaitForInitialization();
p->ReadMarkerSettings();
@ -293,6 +292,13 @@ void MarkerManager::move_marker(size_t from, size_t to)
Q_EMIT MarkersUpdated();
}
// Only use for testing
void MarkerManager::set_marker_settings_path(const std::string& path)
{
p->markerSettingsPath_ = path;
}
std::shared_ptr<MarkerManager> MarkerManager::Instance()
{
static std::weak_ptr<MarkerManager> markerManagerReference_ {};

View file

@ -20,13 +20,16 @@ public:
explicit MarkerManager();
~MarkerManager();
size_t marker_count();
size_t marker_count();
std::optional<types::MarkerInfo> get_marker(size_t index);
void set_marker(size_t index, const types::MarkerInfo& marker);
void add_marker(const types::MarkerInfo& marker);
void remove_marker(size_t index);
void move_marker(size_t from, size_t to);
// Only use for testing
void set_marker_settings_path(const std::string& path);
static std::shared_ptr<MarkerManager> Instance();
signals: