From 399a07b1e2960ea29a64ba528f383ec04bb95597 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 28 Nov 2022 09:39:39 -0600 Subject: [PATCH] ImGui context model test fixes --- .../scwx/qt/model/imgui_context_model.cpp | 5 ++++ .../scwx/qt/model/imgui_context_model.hpp | 2 ++ .../imgui_context_model.test.cpp} | 24 +++++++++---------- test/test.cmake | 6 +++-- 4 files changed, 23 insertions(+), 14 deletions(-) rename test/source/scwx/qt/{manager/imgui_manager.test.cpp => model/imgui_context_model.test.cpp} (58%) diff --git a/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp b/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp index 13b09198..7dd30433 100644 --- a/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp +++ b/scwx-qt/source/scwx/qt/model/imgui_context_model.cpp @@ -130,6 +130,11 @@ void ImGuiContextModel::DestroyContext(const std::string& name) } } +std::vector ImGuiContextModel::contexts() const +{ + return p->contexts_; +} + ImGuiContextModel& ImGuiContextModel::Instance() { static ImGuiContextModel instance_ {}; diff --git a/scwx-qt/source/scwx/qt/model/imgui_context_model.hpp b/scwx-qt/source/scwx/qt/model/imgui_context_model.hpp index 7241a197..c754adbd 100644 --- a/scwx-qt/source/scwx/qt/model/imgui_context_model.hpp +++ b/scwx-qt/source/scwx/qt/model/imgui_context_model.hpp @@ -45,6 +45,8 @@ public: ImGuiContext* CreateContext(const std::string& name); void DestroyContext(const std::string& name); + std::vector contexts() const; + static ImGuiContextModel& Instance(); signals: diff --git a/test/source/scwx/qt/manager/imgui_manager.test.cpp b/test/source/scwx/qt/model/imgui_context_model.test.cpp similarity index 58% rename from test/source/scwx/qt/manager/imgui_manager.test.cpp rename to test/source/scwx/qt/model/imgui_context_model.test.cpp index e25cee22..81000b3b 100644 --- a/test/source/scwx/qt/manager/imgui_manager.test.cpp +++ b/test/source/scwx/qt/model/imgui_context_model.test.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -6,18 +6,18 @@ namespace scwx { namespace qt { -namespace manager +namespace model { -TEST(ImGuiManagerTest, State) +TEST(ImGuiContextModelTest, State) { - auto& ImGuiManager = ImGuiManager::Instance(); + auto& imGuiContextModel = ImGuiContextModel::Instance(); - ImGuiManager.CreateContext("Context One"); - ImGuiManager.CreateContext("Context Two"); - ImGuiManager.CreateContext("Context Three"); - - auto contexts = ImGuiManager.contexts(); + imGuiContextModel.CreateContext("Context One"); + imGuiContextModel.CreateContext("Context Two"); + imGuiContextModel.CreateContext("Context Three"); + + auto contexts = imGuiContextModel.contexts(); ASSERT_EQ(contexts.size(), 3u); EXPECT_EQ(contexts.at(0).id_, 0u); @@ -30,15 +30,15 @@ TEST(ImGuiManagerTest, State) EXPECT_NE(contexts.at(1).context_, nullptr); EXPECT_NE(contexts.at(2).context_, nullptr); - ImGuiManager.DestroyContext("Context Two"); + imGuiContextModel.DestroyContext("Context Two"); - auto contexts2 = ImGuiManager.contexts(); + auto contexts2 = imGuiContextModel.contexts(); ASSERT_EQ(contexts2.size(), 2u); EXPECT_EQ(contexts2.at(0), contexts.at(0)); EXPECT_EQ(contexts2.at(1), contexts.at(2)); } -} // namespace manager +} // namespace model } // namespace qt } // namespace scwx diff --git a/test/test.cmake b/test/test.cmake index 812a70da..dcd547ca 100644 --- a/test/test.cmake +++ b/test/test.cmake @@ -21,8 +21,8 @@ set(SRC_PROVIDER_TESTS source/scwx/provider/aws_level2_data_provider.test.cpp source/scwx/provider/warnings_provider.test.cpp) set(SRC_QT_CONFIG_TESTS source/scwx/qt/config/county_database.test.cpp source/scwx/qt/config/radar_site.test.cpp) -set(SRC_QT_MANAGER_TESTS source/scwx/qt/manager/imgui_manager.test.cpp - source/scwx/qt/manager/settings_manager.test.cpp) +set(SRC_QT_MANAGER_TESTS source/scwx/qt/manager/settings_manager.test.cpp) +set(SRC_QT_MODEL_TESTS source/scwx/qt/model/imgui_context_model.test.cpp) set(SRC_UTIL_TESTS source/scwx/util/float.test.cpp source/scwx/util/rangebuf.test.cpp source/scwx/util/streams.test.cpp @@ -40,6 +40,7 @@ add_executable(wxtest ${SRC_MAIN} ${SRC_PROVIDER_TESTS} ${SRC_QT_CONFIG_TESTS} ${SRC_QT_MANAGER_TESTS} + ${SRC_QT_MODEL_TESTS} ${SRC_UTIL_TESTS} ${SRC_WSR88D_TESTS} ${CMAKE_FILES}) @@ -51,6 +52,7 @@ source_group("Source Files\\network" FILES ${SRC_NETWORK_TESTS}) source_group("Source Files\\provider" FILES ${SRC_PROVIDER_TESTS}) source_group("Source Files\\qt\\config" FILES ${SRC_QT_CONFIG_TESTS}) source_group("Source Files\\qt\\manager" FILES ${SRC_QT_MANAGER_TESTS}) +source_group("Source Files\\qt\\model" FILES ${SRC_QT_MODEL_TESTS}) source_group("Source Files\\util" FILES ${SRC_UTIL_TESTS}) source_group("Source Files\\wsr88d" FILES ${SRC_WSR88D_TESTS})