FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
TestSDLDialogInput.cpp
1#include "../sdl_dialogs.hpp"
2#include "../sdl_input_widget_pair_list.hpp"
3
4#include <freerdp/api.h>
5#include <winpr/wlog.h>
6
7typedef int (*fkt_t)(void);
8
9BOOL sdl_log_error_ex(Sint32 res, wLog* log, const char* what, const char* file, size_t line,
10 const char* fkt)
11{
12 WINPR_UNUSED(file);
13
14 WLog_Print(log, WLOG_ERROR, "[%s:%" PRIuz "][%s]: %s", fkt, line, what, "xxx");
15 return TRUE;
16}
17
18static int auth_dialogs(void)
19{
20 const std::string title = "sometitle";
21 std::vector<std::string> result;
22
23 std::vector<std::string> initial{ "Smartcard", "abc", "def" };
24 std::vector<Uint32> flags = { SdlInputWidgetPair::SDL_INPUT_READONLY,
25 SdlInputWidgetPair::SDL_INPUT_MASK, 0 };
26
27 const std::vector<std::string>& labels{ "foo", "bar", "gaga" };
28
29 SdlInputWidgetPairList ilist(title.c_str(), labels, initial, flags);
30 auto rc = ilist.run(result);
31
32 if ((result.size() < labels.size()))
33 rc = -1;
34 return rc;
35}
36
37static int runTest(fkt_t fkt)
38{
39 int rc;
40
41 SDL_Init(SDL_INIT_VIDEO);
42 sdl_dialogs_init();
43 try
44 {
45 rc = fkt();
46 }
47 catch (int e)
48 {
49 rc = e;
50 }
51 sdl_dialogs_uninit();
52 SDL_Quit();
53 return rc;
54}
55
56int main(int argc, char* argv[])
57{
58 int rc = 0;
59
60 (void)argc;
61 (void)argv;
62
63 rc = runTest(auth_dialogs);
64
65 return rc;
66}