summaryrefslogtreecommitdiffstats
path: root/client/SDL/dialogs/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
commita9bcc81f821d7c66f623779fa5147e728eb3c388 (patch)
tree98676963bcdd537ae5908a067a8eb110b93486a6 /client/SDL/dialogs/test
parentInitial commit. (diff)
downloadfreerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.tar.xz
freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.zip
Adding upstream version 3.3.0+dfsg1.upstream/3.3.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'client/SDL/dialogs/test')
-rw-r--r--client/SDL/dialogs/test/CMakeLists.txt30
-rw-r--r--client/SDL/dialogs/test/TestSDLDialogs.cpp99
2 files changed, 129 insertions, 0 deletions
diff --git a/client/SDL/dialogs/test/CMakeLists.txt b/client/SDL/dialogs/test/CMakeLists.txt
new file mode 100644
index 0000000..c1003d4
--- /dev/null
+++ b/client/SDL/dialogs/test/CMakeLists.txt
@@ -0,0 +1,30 @@
+set(MODULE_NAME "TestSDL")
+set(MODULE_PREFIX "TEST_SDL")
+
+set(DRIVER ${MODULE_NAME}.cpp)
+
+set(TEST_SRCS
+ TestSDLDialogs.cpp
+)
+
+create_test_sourcelist(SRCS
+ ${DRIVER}
+ ${TEST_SRCS})
+
+add_library(${MODULE_NAME} ${SRCS})
+
+list(APPEND LIBS
+ dialogs
+)
+
+target_link_libraries(${MODULE_NAME} ${LIBS})
+
+set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
+
+foreach(test ${TESTS})
+ get_filename_component(TestName ${test} NAME_WE)
+ add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
+endforeach()
+
+set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/Client/Test")
+
diff --git a/client/SDL/dialogs/test/TestSDLDialogs.cpp b/client/SDL/dialogs/test/TestSDLDialogs.cpp
new file mode 100644
index 0000000..558fb4c
--- /dev/null
+++ b/client/SDL/dialogs/test/TestSDLDialogs.cpp
@@ -0,0 +1,99 @@
+#include "../sdl_selectlist.hpp"
+#include "../sdl_input_widgets.hpp"
+
+#include <freerdp/api.h>
+#include <winpr/wlog.h>
+
+BOOL sdl_log_error_ex(Uint32 res, wLog* log, const char* what, const char* file, size_t line,
+ const char* fkt)
+{
+ return FALSE;
+}
+
+static bool test_input_dialog()
+{
+ const auto title = "sometitle";
+ std::vector<std::string> labels;
+ std::vector<std::string> initial;
+ std::vector<Uint32> flags;
+ for (size_t x = 0; x < 12; x++)
+ {
+ labels.push_back("label" + std::to_string(x));
+ initial.push_back(std::to_string(x));
+
+ Uint32 flag = 0;
+ if ((x % 2) != 0)
+ flag |= SdlInputWidget::SDL_INPUT_MASK;
+ if ((x % 3) == 0)
+ flag |= SdlInputWidget::SDL_INPUT_READONLY;
+
+ flags.push_back(flag);
+ }
+ SdlInputWidgetList list{ title, labels, initial, flags };
+ std::vector<std::string> result;
+ auto rc = list.run(result);
+ if (rc < 0)
+ {
+ return false;
+ }
+ if (result.size() != labels.size())
+ {
+ return false;
+ }
+ return true;
+}
+
+static bool test_select_dialog()
+{
+ const auto title = "sometitle";
+ std::vector<std::string> labels;
+ for (size_t x = 0; x < 12; x++)
+ {
+ labels.push_back("label" + std::to_string(x));
+ }
+ SdlSelectList list{ title, labels };
+ auto rc = list.run();
+ if (rc < 0)
+ {
+ return false;
+ }
+ if (static_cast<size_t>(rc) >= labels.size())
+ return false;
+
+ return true;
+}
+
+extern "C"
+{
+ FREERDP_API int TestSDLDialogs(int argc, char* argv[]);
+}
+
+int TestSDLDialogs(int argc, char* argv[])
+{
+ int rc = 0;
+
+ (void)argc;
+ (void)argv;
+
+#if 0
+ SDL_Init(SDL_INIT_VIDEO);
+ try
+ {
+#if 1
+ if (!test_input_dialog())
+ throw -1;
+#endif
+#if 1
+ if (!test_select_dialog())
+ throw -2;
+#endif
+ }
+ catch (int e)
+ {
+ rc = e;
+ }
+ SDL_Quit();
+
+#endif
+ return rc;
+}