3 #include <winpr/crypto.h>
5 #include <freerdp/settings.h>
6 #include <freerdp/codecs.h>
8 #include "settings_property_lists.h"
9 #include "../settings.h"
11 static BOOL log_result(BOOL value,
const char* fkt)
13 (void)fprintf(stderr,
"TestSettings [%s] returned %s\n", fkt, value ?
"TRUE" :
"FALSE");
17 static BOOL log_result_case(BOOL value,
const char* fkt,
size_t testcase)
19 (void)fprintf(stderr,
"TestSettings [%s] testcase %" PRIuz
" returned %s\n", fkt, testcase,
20 value ?
"TRUE" :
"FALSE");
33 if (got->argc != expect->argc)
36 for (
int x = 0; x < expect->argc; x++)
38 if (strcmp(got->argv[x], expect->argv[x]) != 0)
41 return log_result(rc, __func__);
44 static BOOL test_dyn_channels(
void)
50 const char* argv1[] = {
"foobar" };
53 const char* argv2[] = {
"gaga",
"abba",
"foo" };
66 test = freerdp_dynamic_channel_collection_del(settings,
"foobar");
69 got = freerdp_dynamic_channel_collection_find(settings,
"foobar");
74 cmp1 = args1 = freerdp_addin_argv_new(ARRAYSIZE(argv1), argv1);
75 test = freerdp_dynamic_channel_collection_add(settings, args1);
87 cmp2 = args2 = freerdp_addin_argv_new(ARRAYSIZE(argv2), argv2);
88 test = freerdp_dynamic_channel_collection_add(settings, args2);
101 got = freerdp_dynamic_channel_collection_find(settings,
"foobar");
102 if (!compare(got, cmp1))
104 got = freerdp_dynamic_channel_collection_find(settings,
"gaga");
105 if (!compare(got, cmp2))
107 test = freerdp_dynamic_channel_collection_del(settings,
"foobar");
116 got = freerdp_dynamic_channel_collection_find(settings,
"foobar");
117 if (compare(got, cmp1))
119 got = freerdp_dynamic_channel_collection_find(settings,
"gaga");
120 if (!compare(got, cmp2))
122 test = freerdp_dynamic_channel_collection_del(settings,
"gaga");
128 got = freerdp_dynamic_channel_collection_find(settings,
"foobar");
129 if (compare(got, cmp1))
131 got = freerdp_dynamic_channel_collection_find(settings,
"gaga");
132 if (compare(got, cmp2))
139 freerdp_addin_argv_free(args1);
140 freerdp_addin_argv_free(args2);
141 return log_result(rc, __func__);
144 static BOOL test_static_channels(
void)
150 const char* argv1[] = {
"foobar" };
153 const char* argv2[] = {
"gaga",
"abba",
"foo" };
166 test = freerdp_static_channel_collection_del(settings,
"foobar");
169 got = freerdp_static_channel_collection_find(settings,
"foobar");
174 cmp1 = args1 = freerdp_addin_argv_new(ARRAYSIZE(argv1), argv1);
175 test = freerdp_static_channel_collection_add(settings, args1);
187 cmp2 = args2 = freerdp_addin_argv_new(ARRAYSIZE(argv2), argv2);
188 test = freerdp_static_channel_collection_add(settings, args2);
201 got = freerdp_static_channel_collection_find(settings,
"foobar");
202 if (!compare(got, cmp1))
204 got = freerdp_static_channel_collection_find(settings,
"gaga");
205 if (!compare(got, cmp2))
207 test = freerdp_static_channel_collection_del(settings,
"foobar");
216 got = freerdp_static_channel_collection_find(settings,
"foobar");
217 if (compare(got, cmp1))
219 got = freerdp_static_channel_collection_find(settings,
"gaga");
220 if (!compare(got, cmp2))
222 test = freerdp_static_channel_collection_del(settings,
"gaga");
228 got = freerdp_static_channel_collection_find(settings,
"foobar");
229 if (compare(got, cmp1))
231 got = freerdp_static_channel_collection_find(settings,
"gaga");
232 if (compare(got, cmp2))
239 freerdp_addin_argv_free(args1);
240 freerdp_addin_argv_free(args2);
241 return log_result(rc, __func__);
244 static BOOL test_copy(
void)
247 wLog* log = WLog_Get(__func__);
252 if (!settings || !copy || !modified)
267 return log_result(rc, __func__);
270 static BOOL test_helpers(
void)
282 if (flags != FREERDP_CODEC_ALL)
288 if (flags != (FREERDP_CODEC_ALL & ~FREERDP_CODEC_NSCODEC))
294 if (flags != (FREERDP_CODEC_ALL & ~(FREERDP_CODEC_NSCODEC | FREERDP_CODEC_REMOTEFX)))
300 if (flags != (FREERDP_CODEC_ALL & ~FREERDP_CODEC_REMOTEFX))
306 return log_result(rc, __func__);
309 static BOOL format_uint(
char* buffer,
size_t size, UINT64 value, UINT16 intType, UINT64 max)
311 const UINT64 lvalue = value > max ? max : value;
312 intType = intType % 3;
316 (void)_snprintf(buffer, size,
"%" PRIu64, lvalue);
319 (void)_snprintf(buffer, size,
"0x%" PRIx64, lvalue);
322 if (max < UINT64_MAX)
323 (void)_snprintf(buffer, size,
"%" PRIu64, max + 1);
325 (
void)_snprintf(buffer, size,
"too large a number");
328 (void)_snprintf(buffer, size,
"not a number value");
333 static BOOL print_negative(
char* buffer,
size_t size, INT64 value, INT64 min)
338 (void)_snprintf(buffer, size,
"%" PRId16, (INT16)value);
341 (void)_snprintf(buffer, size,
"%" PRId32, (INT32)value);
344 (void)_snprintf(buffer, size,
"%" PRId64, value);
347 (void)_snprintf(buffer, size,
"too small a number");
352 static BOOL print_xpositive(
char* buffer,
size_t size, INT64 value, INT64 max)
356 (void)_snprintf(buffer, size,
"%" PRId64, value);
363 (void)_snprintf(buffer, size,
"%" PRIx16, (INT16)value);
366 (void)_snprintf(buffer, size,
"%" PRIx32, (INT32)value);
369 (void)_snprintf(buffer, size,
"%" PRIx64, value);
372 (void)_snprintf(buffer, size,
"too small a number");
377 static BOOL format_int(
char* buffer,
size_t size, INT64 value, UINT16 intType, INT64 max, INT64 min)
379 const INT64 lvalue = (value > max) ? max : ((value < min) ? min : value);
380 intType = intType % 4;
385 (void)_snprintf(buffer, size,
"%" PRId64, lvalue);
388 print_xpositive(buffer, size, lvalue, max);
392 (void)_snprintf(buffer, size,
"%" PRId64, max + 1);
394 (
void)_snprintf(buffer, size,
"too large a number");
398 print_negative(buffer, size, min - 1, INT64_MIN);
400 (
void)_snprintf(buffer, size,
"too small a number");
403 (void)_snprintf(buffer, size,
"not a number value");
408 static BOOL format_bool(
char* buffer,
size_t size, UINT16 intType)
410 intType = intType % 10;
414 (void)_snprintf(buffer, size,
"FALSE");
417 (void)_snprintf(buffer, size,
"FaLsE");
420 (void)_snprintf(buffer, size,
"False");
423 (void)_snprintf(buffer, size,
"false");
426 (void)_snprintf(buffer, size,
"falseentry");
429 (void)_snprintf(buffer, size,
"TRUE");
432 (void)_snprintf(buffer, size,
"TrUe");
435 (void)_snprintf(buffer, size,
"True");
438 (void)_snprintf(buffer, size,
"true");
441 (void)_snprintf(buffer, size,
"someentry");
444 (void)_snprintf(buffer, size,
"ok");
449 static BOOL check_key_helpers(
size_t key,
const char* stype)
451 int test_rounds = 100;
453 rdpSettings* settings = NULL;
457 const size_t clear_keys[] = { FreeRDP_RdpServerCertificate,
458 FreeRDP_RdpServerRsaKey,
459 FreeRDP_RedirectionPassword,
460 FreeRDP_RedirectionTsvUrl,
461 FreeRDP_LoadBalanceInfo,
462 FreeRDP_ServerRandom,
463 FreeRDP_ClientRandom,
464 FreeRDP_ServerCertificate,
465 FreeRDP_TargetNetAddresses,
466 FreeRDP_ReceivedCapabilities,
467 FreeRDP_ServerLicenseProductIssuers,
468 FreeRDP_TargetNetPorts,
470 FreeRDP_ChannelDefArray,
471 FreeRDP_MonitorDefArray,
472 FreeRDP_ClientAutoReconnectCookie,
473 FreeRDP_ServerAutoReconnectCookie,
474 FreeRDP_ClientTimeZone,
475 FreeRDP_BitmapCacheV2CellInfo,
478 FreeRDP_StaticChannelArray,
479 FreeRDP_DynamicChannelArray,
480 FreeRDP_ReceivedCapabilities,
481 FreeRDP_OrderSupport,
482 FreeRDP_MonitorIds };
486 printf(
"[%s] missing name for key %" PRIuz
"\n", stype, key);
492 printf(
"[%s] missing reverse name for key %s [%" PRIuz
"]\n", stype, name, key);
495 if ((
size_t)tkey != key)
497 printf(
"[%s] mismatch reverse name for key %s [%" PRIuz
"]: %" PRIdz
"\n", stype, name, key,
504 printf(
"[%s] missing reverse type for key %s [%" PRIuz
"]\n", stype, name, key);
510 printf(
"[%s] missing reverse name for key %s [%" PRIuz
"]\n", stype, name, key);
516 printf(
"[%s] mismatch reverse type for key %s [%" PRIuz
"]: %" PRIdz
" <--> %" PRIdz
"\n",
517 stype, name, key, rc, type);
524 printf(
"[%s] freerdp_settings_new failed\n", stype);
527 for (
size_t x = 0; x < ARRAYSIZE(clear_keys); x++)
529 const size_t id = clear_keys[x];
533 printf(
"[%s] freerdp_settings_set_pointer_len(%s, NULL, 0) failed\n", stype, foo);
539 UINT16 intEntryType = 0;
542 char value[8192] = { 0 };
554 winpr_RAND(&intEntryType,
sizeof(intEntryType));
555 winpr_RAND(&val.u64,
sizeof(val.u64));
559 case RDP_SETTINGS_TYPE_BOOL:
560 expect = format_bool(value,
sizeof(value), intEntryType);
562 case RDP_SETTINGS_TYPE_UINT16:
563 expect = format_uint(value,
sizeof(value), val.u64, intEntryType, UINT16_MAX);
565 case RDP_SETTINGS_TYPE_INT16:
567 format_int(value,
sizeof(value), val.i64, intEntryType, INT16_MAX, INT16_MIN);
569 case RDP_SETTINGS_TYPE_UINT32:
570 expect = format_uint(value,
sizeof(value), val.u64, intEntryType, UINT32_MAX);
572 case RDP_SETTINGS_TYPE_INT32:
574 format_int(value,
sizeof(value), val.i64, intEntryType, INT32_MAX, INT32_MIN);
576 case RDP_SETTINGS_TYPE_UINT64:
577 expect = format_uint(value,
sizeof(value), val.u64, intEntryType, UINT64_MAX);
579 case RDP_SETTINGS_TYPE_INT64:
581 format_int(value,
sizeof(value), val.i64, intEntryType, INT64_MAX, INT64_MIN);
583 case RDP_SETTINGS_TYPE_STRING:
585 (void)_snprintf(value,
sizeof(value),
"somerandomstring");
587 case RDP_SETTINGS_TYPE_POINTER:
592 printf(
"[%s] invalid type for key %s [%" PRIuz
"]: %" PRIdz
" <--> %" PRIdz
"\n",
593 stype, name, key, rc, type);
597 have = freerdp_settings_set_value_for_name(settings, name, value);
600 printf(
"[%s] have[%s] != expect[%s]\n", stype, have ?
"TRUE" :
"FALSE",
601 expect ?
"TRUE" :
"FALSE");
605 }
while (test_rounds-- > 0);
610 return log_result(res, __func__);
613 static BOOL check_args(
const RDPDR_DEVICE* what,
size_t count,
const char* args[])
619 if (strcmp(what->Name, args[0]) != 0)
625 case RDPDR_DTYP_PRINT:
632 return strcmp(a->DriverName, args[1]) == 0;
635 case RDPDR_DTYP_SERIAL:
643 if (strcmp(a->Path, args[1]) != 0)
651 if (strcmp(a->Driver, args[2]) != 0)
659 if (strcmp(a->Permissive, args[3]) != 0)
665 case RDPDR_DTYP_PARALLEL:
672 return strcmp(a->Path, args[1]) == 0;
675 case RDPDR_DTYP_SMARTCARD:
678 case RDPDR_DTYP_FILESYSTEM:
685 if (strcmp(a->Path, args[1]) != 0)
690 return a->automount == (args[2] == NULL) ? TRUE : FALSE;
693 return !a->automount;
701 static int check_device_type_arg(UINT32 Type,
size_t count,
const char* args[])
704 RDPDR_DEVICE* device = freerdp_device_new(Type, count, args);
715 if (!check_args(device, count, args))
719 if (!freerdp_device_equal(clone, device))
724 freerdp_device_free(device);
725 freerdp_device_free(clone);
726 return log_result(rc, __func__);
729 static BOOL check_device_type(
void)
738 const char* args[] = {
"somename",
"anothername",
"3rdname",
"4thname" };
739 const struct test_entry tests[] = {
740 { 1, RDPDR_DTYP_SERIAL, 0, NULL },
741 { 1, RDPDR_DTYP_SERIAL, 0, args },
742 { 1, RDPDR_DTYP_SERIAL, 1, args },
743 { 1, RDPDR_DTYP_SERIAL, 2, args },
744 { 1, RDPDR_DTYP_SERIAL, 3, args },
745 { 1, RDPDR_DTYP_SERIAL, 4, args },
746 { 1, RDPDR_DTYP_PARALLEL, 0, NULL },
747 { 1, RDPDR_DTYP_PARALLEL, 0, args },
748 { 1, RDPDR_DTYP_PARALLEL, 1, args },
749 { 1, RDPDR_DTYP_PARALLEL, 2, args },
750 { 1, RDPDR_DTYP_PARALLEL, 3, args },
751 { 1, RDPDR_DTYP_PARALLEL, 4, args },
752 { 1, RDPDR_DTYP_PRINT, 0, NULL },
753 { 1, RDPDR_DTYP_PRINT, 0, args },
754 { 1, RDPDR_DTYP_PRINT, 1, args },
755 { 1, RDPDR_DTYP_PRINT, 2, args },
756 { 1, RDPDR_DTYP_PRINT, 3, args },
757 { 1, RDPDR_DTYP_PRINT, 4, args },
758 { 1, RDPDR_DTYP_FILESYSTEM, 0, NULL },
759 { 1, RDPDR_DTYP_FILESYSTEM, 0, args },
760 { 1, RDPDR_DTYP_FILESYSTEM, 1, args },
761 { 1, RDPDR_DTYP_FILESYSTEM, 2, args },
762 { 1, RDPDR_DTYP_FILESYSTEM, 3, args },
763 { 1, RDPDR_DTYP_FILESYSTEM, 4, args },
764 { 1, RDPDR_DTYP_SMARTCARD, 0, NULL },
765 { 1, RDPDR_DTYP_SMARTCARD, 0, args },
766 { 1, RDPDR_DTYP_SMARTCARD, 1, args },
767 { 1, RDPDR_DTYP_SMARTCARD, 2, args },
768 { 1, RDPDR_DTYP_SMARTCARD, 3, args },
769 { 1, RDPDR_DTYP_SMARTCARD, 4, args },
770 { -3, 0x123, 0, NULL },
771 { -3, 0x123, 0, args },
772 { -3, 0x123, 1, args },
773 { -3, 0x123, 2, args },
774 { -3, 0x123, 3, args },
775 { -3, 0x123, 4, args },
778 for (
size_t x = 0; x < ARRAYSIZE(tests); x++)
780 const struct test_entry* cur = &tests[x];
781 int got = check_device_type_arg(cur->type, cur->count, cur->args);
782 if (got != cur->expect)
785 return log_result(rc, __func__);
788 static BOOL check_offsets(rdpSettings* settings,
size_t id,
size_t min,
size_t max, BOOL checkPtr)
792 WINPR_ASSERT(settings);
797 for (
size_t x = min; x < max; x++)
799 const void* ptr = freerdp_settings_get_pointer_array(settings,
id, x);
800 if (!ptr && checkPtr)
803 return log_result(rc, __func__);
806 static BOOL test_write_offsets(rdpSettings* settings,
size_t id,
size_t elementSize,
size_t min,
809 WINPR_ASSERT(settings);
811 for (
size_t x = min; x < max; x++)
813 const void* ptr = NULL;
814 char buffer[8192] = { 0 };
816 winpr_RAND(buffer,
sizeof(buffer));
817 if (!freerdp_settings_set_pointer_array(settings,
id, x, buffer))
819 ptr = freerdp_settings_get_pointer_array(settings,
id, x);
822 if (memcmp(ptr, buffer, elementSize) != 0)
828 static BOOL test_pointer_array(
void)
830 struct pointer_test_case
839 const struct pointer_test_case tests[] = {
840 { FALSE, FALSE, FreeRDP_DeviceArray, FreeRDP_DeviceArraySize, 32,
sizeof(
RDPDR_DEVICE*) },
841 { FALSE, FALSE, FreeRDP_StaticChannelArray, FreeRDP_StaticChannelArraySize, 32,
843 { FALSE, FALSE, FreeRDP_DynamicChannelArray, FreeRDP_DynamicChannelArraySize, 33,
845 { TRUE, TRUE, FreeRDP_BitmapCacheV2CellInfo, FreeRDP_BitmapCacheV2NumCells, 5,
847 { FALSE, FALSE, FreeRDP_OrderSupport, -1, 32,
sizeof(BYTE) },
848 { FALSE, FALSE, FreeRDP_ReceivedCapabilities, -1, 32,
sizeof(BYTE) },
851 { TRUE, TRUE, FreeRDP_MonitorIds, FreeRDP_NumMonitorIds, 33,
sizeof(UINT32) },
852 { TRUE, TRUE, FreeRDP_ChannelDefArray, FreeRDP_ChannelDefArraySize, 42,
854 { TRUE, TRUE, FreeRDP_MonitorDefArray, FreeRDP_MonitorDefArraySize, 33,
857 { FALSE, FALSE, FreeRDP_RdpServerCertificate, -1, 1,
sizeof(rdpCertificate*) },
859 { TRUE, TRUE, FreeRDP_RedirectionPassword, FreeRDP_RedirectionPasswordLength, 42,
861 { TRUE, TRUE, FreeRDP_RedirectionTsvUrl, FreeRDP_RedirectionTsvUrlLength, 42,
863 { TRUE, TRUE, FreeRDP_LoadBalanceInfo, FreeRDP_LoadBalanceInfoLength, 42,
sizeof(char) },
864 { TRUE, TRUE, FreeRDP_ServerRandom, FreeRDP_ServerRandomLength, 42,
sizeof(char) },
865 { TRUE, TRUE, FreeRDP_ClientRandom, FreeRDP_ClientRandomLength, 42,
sizeof(char) },
866 { TRUE, TRUE, FreeRDP_ServerCertificate, FreeRDP_ServerCertificateLength, 42,
876 for (
size_t x = 0; x < ARRAYSIZE(tests); x++)
878 const struct pointer_test_case* cur = &tests[x];
881 if (cur->sizeId >= 0)
887 if (!check_offsets(settings, cur->id, 0, cur->size, cur->checkPtr))
889 if (check_offsets(settings, cur->id, cur->size, cur->size + 5, TRUE))
893 if (!test_write_offsets(settings, cur->id, cur->elementSize, 0, cur->size))
895 if (test_write_offsets(settings, cur->id, cur->elementSize, cur->size, cur->size + 5))
900 if (cur->sizeId >= 0)
906 if (check_offsets(settings, cur->id, 0, cur->size, cur->checkPtr))
910 if (test_write_offsets(settings, cur->id, cur->elementSize, 0, cur->size))
915 if (cur->sizeId >= 0)
921 if (!check_offsets(settings, cur->id, 0, cur->size, cur->checkPtr))
923 if (check_offsets(settings, cur->id, cur->size + 1, cur->size + 5, TRUE))
927 if (!test_write_offsets(settings, cur->id, cur->elementSize, 0, cur->size))
929 if (test_write_offsets(settings, cur->id, cur->elementSize, cur->size, cur->size + 5))
938 return log_result(rc, __func__);
941 struct validity_test_case
948 static BOOL prepare_monitor_array(rdpSettings* settings,
const struct validity_test_case* testcase)
950 WINPR_ASSERT(settings);
951 WINPR_ASSERT(testcase);
954 if (count < testcase->count)
956 (void)fprintf(stderr,
"MonitorDefArraySize=%" PRIuz
", but testcase requires %" PRIuz
"\n",
957 count, testcase->count);
960 for (
size_t x = 0; x < testcase->count; x++)
962 const rdpMonitor* monitor = &testcase->monitors[x];
963 if (!freerdp_settings_set_pointer_array(settings, FreeRDP_MonitorDefArray, x, monitor))
969 static BOOL test_validity_check(
void)
983 .attributes = { .physicalWidth = 100,
984 .physicalHeight = 100,
985 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
986 .desktopScaleFactor = 100,
987 .deviceScaleFactor = 100 } }
989 const rdpMonitor single_monitor_invalid_1[] = {
996 .attributes = { .physicalWidth = 100,
997 .physicalHeight = 100,
998 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
999 .desktopScaleFactor = 100,
1000 .deviceScaleFactor = 100 } }
1002 const rdpMonitor single_monitor_invalid_2[] = {
1009 .attributes = { .physicalWidth = 100,
1010 .physicalHeight = 100,
1011 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1012 .desktopScaleFactor = 100,
1013 .deviceScaleFactor = 100 } }
1015 const rdpMonitor single_monitor_invalid_3[] = {
1022 .attributes = { .physicalWidth = 100,
1023 .physicalHeight = 100,
1024 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1025 .desktopScaleFactor = 100,
1026 .deviceScaleFactor = 100 } }
1028 const rdpMonitor single_monitor_invalid_4[] = {
1035 .attributes = { .physicalWidth = 100,
1036 .physicalHeight = 100,
1037 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1038 .desktopScaleFactor = 100,
1039 .deviceScaleFactor = 100 } }
1046 .is_primary = FALSE,
1048 .attributes = { .physicalWidth = 100,
1049 .physicalHeight = 100,
1050 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1051 .desktopScaleFactor = 100,
1052 .deviceScaleFactor = 100 } },
1057 .is_primary = FALSE,
1059 .attributes = { .physicalWidth = 100,
1060 .physicalHeight = 100,
1061 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1062 .desktopScaleFactor = 100,
1063 .deviceScaleFactor = 100 } },
1068 .is_primary = FALSE,
1070 .attributes = { .physicalWidth = 100,
1071 .physicalHeight = 100,
1072 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1073 .desktopScaleFactor = 100,
1074 .deviceScaleFactor = 100 } },
1079 .is_primary = FALSE,
1081 .attributes = { .physicalWidth = 100,
1082 .physicalHeight = 100,
1083 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1084 .desktopScaleFactor = 100,
1085 .deviceScaleFactor = 100 } },
1092 .attributes = { .physicalWidth = 100,
1093 .physicalHeight = 100,
1094 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1095 .desktopScaleFactor = 100,
1096 .deviceScaleFactor = 100 } },
1101 .is_primary = FALSE,
1103 .attributes = { .physicalWidth = 100,
1104 .physicalHeight = 100,
1105 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1106 .desktopScaleFactor = 100,
1107 .deviceScaleFactor = 100 } },
1112 .is_primary = FALSE,
1114 .attributes = { .physicalWidth = 100,
1115 .physicalHeight = 100,
1116 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1117 .desktopScaleFactor = 100,
1118 .deviceScaleFactor = 100 } },
1123 .is_primary = FALSE,
1125 .attributes = { .physicalWidth = 100,
1126 .physicalHeight = 100,
1127 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1128 .desktopScaleFactor = 100,
1129 .deviceScaleFactor = 100 } },
1134 .is_primary = FALSE,
1136 .attributes = { .physicalWidth = 100,
1137 .physicalHeight = 100,
1138 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1139 .desktopScaleFactor = 100,
1140 .deviceScaleFactor = 100 } },
1145 .is_primary = FALSE,
1147 .attributes = { .physicalWidth = 100,
1148 .physicalHeight = 100,
1149 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1150 .desktopScaleFactor = 100,
1151 .deviceScaleFactor = 100 } },
1156 .is_primary = FALSE,
1158 .attributes = { .physicalWidth = 100,
1159 .physicalHeight = 100,
1160 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1161 .desktopScaleFactor = 100,
1162 .deviceScaleFactor = 100 } },
1167 .is_primary = FALSE,
1169 .attributes = { .physicalWidth = 100,
1170 .physicalHeight = 100,
1171 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1172 .desktopScaleFactor = 100,
1173 .deviceScaleFactor = 100 } },
1175 const rdpMonitor multi_monitor_invalid_1[] = {
1180 .is_primary = FALSE,
1182 .attributes = { .physicalWidth = 100,
1183 .physicalHeight = 100,
1184 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1185 .desktopScaleFactor = 100,
1186 .deviceScaleFactor = 100 } },
1191 .is_primary = FALSE,
1193 .attributes = { .physicalWidth = 100,
1194 .physicalHeight = 100,
1195 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1196 .desktopScaleFactor = 100,
1197 .deviceScaleFactor = 100 } }
1199 const rdpMonitor multi_monitor_invalid_2[] = {
1204 .is_primary = FALSE,
1206 .attributes = { .physicalWidth = 100,
1207 .physicalHeight = 100,
1208 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1209 .desktopScaleFactor = 100,
1210 .deviceScaleFactor = 100 } },
1217 .attributes = { .physicalWidth = 100,
1218 .physicalHeight = 100,
1219 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1220 .desktopScaleFactor = 100,
1221 .deviceScaleFactor = 100 } }
1223 const rdpMonitor multi_monitor_invalid_3[] = {
1228 .is_primary = FALSE,
1230 .attributes = { .physicalWidth = 100,
1231 .physicalHeight = 100,
1232 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1233 .desktopScaleFactor = 100,
1234 .deviceScaleFactor = 100 } },
1241 .attributes = { .physicalWidth = 100,
1242 .physicalHeight = 100,
1243 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1244 .desktopScaleFactor = 100,
1245 .deviceScaleFactor = 100 } }
1247 const rdpMonitor multi_monitor_invalid_4[] = {
1252 .is_primary = FALSE,
1254 .attributes = { .physicalWidth = 100,
1255 .physicalHeight = 100,
1256 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1257 .desktopScaleFactor = 100,
1258 .deviceScaleFactor = 100 } },
1265 .attributes = { .physicalWidth = 100,
1266 .physicalHeight = 100,
1267 .orientation = ORIENTATION_PREFERENCE_LANDSCAPE,
1268 .desktopScaleFactor = 100,
1269 .deviceScaleFactor = 100 } }
1272 const struct validity_test_case tests[] = {
1273 { TRUE, ARRAYSIZE(single_monitor_valid), single_monitor_valid },
1274 { FALSE, ARRAYSIZE(single_monitor_invalid_1), single_monitor_invalid_1 },
1275 { FALSE, ARRAYSIZE(single_monitor_invalid_2), single_monitor_invalid_2 },
1276 { FALSE, ARRAYSIZE(single_monitor_invalid_3), single_monitor_invalid_3 },
1277 { FALSE, ARRAYSIZE(single_monitor_invalid_4), single_monitor_invalid_4 },
1278 { TRUE, ARRAYSIZE(multi_monitor_valid), multi_monitor_valid },
1279 { FALSE, ARRAYSIZE(multi_monitor_invalid_1), multi_monitor_invalid_1 },
1280 { FALSE, ARRAYSIZE(multi_monitor_invalid_2), multi_monitor_invalid_2 },
1281 { FALSE, ARRAYSIZE(multi_monitor_invalid_3), multi_monitor_invalid_3 },
1282 { FALSE, ARRAYSIZE(multi_monitor_invalid_4), multi_monitor_invalid_4 },
1286 for (
size_t x = 0; x < ARRAYSIZE(tests); x++)
1288 const struct validity_test_case* cur = &tests[x];
1290 if (!prepare_monitor_array(settings, cur))
1291 rc = log_result_case(FALSE, __func__, x);
1294 #if defined(BUILD_TESTING_INTERNAL)
1295 const BOOL res = freerdp_settings_check_client_after_preconnect(settings);
1297 const BOOL res = cur->expected;
1299 if (res != cur->expected)
1301 rc = log_result_case(FALSE, __func__, x);
1308 return log_result(rc, __func__);
1311 int TestSettings(
int argc,
char* argv[])
1314 rdpSettings* settings = NULL;
1315 rdpSettings* cloned = NULL;
1316 rdpSettings* cloned2 = NULL;
1320 if (!test_dyn_channels())
1322 if (!test_static_channels())
1326 if (!test_helpers())
1328 if (!check_device_type())
1330 if (!test_pointer_array())
1332 if (!test_validity_check())
1339 printf(
"Couldn't create settings\n");
1353 #if defined(have_bool_list_indices)
1355 for (
size_t x = 0; x < ARRAYSIZE(bool_list_indices); x++)
1357 const size_t key = bool_list_indices[x];
1363 printf(
"mismatch for key %s: %u -> copy %u\n", name, val, cval);
1368 if (!check_key_helpers(key,
"bool"))
1373 #if defined(have_int16_list_indices)
1375 for (
size_t x = 0; x < ARRAYSIZE(int16_list_indices); x++)
1377 const size_t key = int16_list_indices[x];
1383 printf(
"mismatch for key %s: %" PRId16
" -> copy %" PRId16
"\n", name, val, cval);
1388 if (!check_key_helpers(key,
"int16"))
1393 #if defined(have_uint16_list_indices)
1395 for (
size_t x = 0; x < ARRAYSIZE(uint16_list_indices); x++)
1397 const size_t key = uint16_list_indices[x];
1403 printf(
"mismatch for key %s: %" PRIu16
" -> copy %" PRIu16
"\n", name, val, cval);
1408 if (!check_key_helpers(key,
"uint16"))
1413 #if defined(have_uint32_list_indices)
1415 for (
size_t x = 0; x < ARRAYSIZE(uint32_list_indices); x++)
1417 const size_t key = uint32_list_indices[x];
1423 printf(
"mismatch for key %s: %" PRIu32
" -> copy %" PRIu32
"\n", name, val, cval);
1428 if (!check_key_helpers(key,
"uint32"))
1433 #if defined(have_int32_list_indices)
1435 for (
size_t x = 0; x < ARRAYSIZE(int32_list_indices); x++)
1437 const size_t key = int32_list_indices[x];
1443 printf(
"mismatch for key %s: %" PRId32
" -> copy %" PRId32
"\n", name, val, cval);
1448 if (!check_key_helpers(key,
"int32"))
1453 #if defined(have_uint64_list_indices)
1455 for (
size_t x = 0; x < ARRAYSIZE(uint64_list_indices); x++)
1457 const size_t key = uint64_list_indices[x];
1463 printf(
"mismatch for key %s: %" PRIu64
" -> copy %" PRIu64
"\n", name, val, cval);
1468 if (!check_key_helpers(key,
"uint64"))
1473 #if defined(have_int64_list_indices)
1475 for (
size_t x = 0; x < ARRAYSIZE(int64_list_indices); x++)
1477 const size_t key = int64_list_indices[x];
1483 printf(
"mismatch for key %s: %" PRId64
" -> copy %" PRId64
"\n", name, val, cval);
1488 if (!check_key_helpers(key,
"int64"))
1493 #if defined(have_string_list_indices)
1495 for (
size_t x = 0; x < ARRAYSIZE(string_list_indices); x++)
1497 const size_t key = string_list_indices[x];
1498 const char val[] =
"test-string";
1499 const char* res = NULL;
1503 if ((oval != cval) && (strcmp(oval, cval) != 0))
1505 printf(
"mismatch for key %s: %s -> copy %s\n", name, oval, cval);
1513 if (strncmp(val, res,
sizeof(val)) != 0)
1518 #if defined(have_pointer_list_indices)
1520 for (
size_t x = 0; x < ARRAYSIZE(pointer_list_indices); x++)
1522 const size_t key = pointer_list_indices[x];
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_set_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *param)
Sets a string settings value. The param is copied.
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
FREERDP_API const void * freerdp_settings_get_pointer(const rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a immutable pointer settings value.
FREERDP_API INT64 freerdp_settings_get_int64(const rdpSettings *settings, FreeRDP_Settings_Keys_Int64 id)
Returns a INT64 settings value.
FREERDP_API BOOL freerdp_settings_print_diff(wLog *log, DWORD level, const rdpSettings *src, const rdpSettings *other)
Dumps the difference between two settings structs to a WLog.
FREERDP_API SSIZE_T freerdp_settings_get_type_for_name(const char *value)
Get a key type for the name string of that key.
FREERDP_API SSIZE_T freerdp_settings_get_type_for_key(SSIZE_T key)
Get a key type for the key index.
FREERDP_API rdpSettings * freerdp_settings_new(DWORD flags)
creates a new setting struct
FREERDP_API UINT64 freerdp_settings_get_uint64(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt64 id)
Returns a UINT64 settings value.
FREERDP_API SSIZE_T freerdp_settings_get_key_for_name(const char *value)
Get a key index for the name string of that key.
FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
FREERDP_API BOOL freerdp_settings_set_pointer_len(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id, const void *data, size_t len)
Set a pointer to value data.
FREERDP_API BOOL freerdp_settings_set_int32(rdpSettings *settings, FreeRDP_Settings_Keys_Int32 id, INT32 param)
Sets a INT32 settings value.
FREERDP_API void freerdp_settings_free(rdpSettings *settings)
Free a settings struct with all data in it.
FREERDP_API UINT16 freerdp_settings_get_uint16(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt16 id)
Returns a UINT16 settings value.
FREERDP_API BOOL freerdp_settings_copy(rdpSettings *dst, const rdpSettings *src)
Deep copies settings from src to dst.
FREERDP_API rdpSettings * freerdp_settings_clone(const rdpSettings *settings)
Creates a deep copy of settings.
FREERDP_API BOOL freerdp_settings_set_uint64(rdpSettings *settings, FreeRDP_Settings_Keys_UInt64 id, UINT64 param)
Sets a UINT64 settings value.
FREERDP_API BOOL freerdp_settings_set_int16(rdpSettings *settings, FreeRDP_Settings_Keys_Int16 id, INT16 param)
Sets a INT16 settings value.
FREERDP_API BOOL freerdp_settings_set_int64(rdpSettings *settings, FreeRDP_Settings_Keys_Int64 id, INT64 param)
Sets a INT64 settings value.
FREERDP_API INT32 freerdp_settings_get_int32(const rdpSettings *settings, FreeRDP_Settings_Keys_Int32 id)
Returns a INT32 settings value.
FREERDP_API UINT32 freerdp_settings_get_codecs_flags(const rdpSettings *settings)
helper function to get a mask of supported codec flags.
FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 param)
Sets a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_set_uint16(rdpSettings *settings, FreeRDP_Settings_Keys_UInt16 id, UINT16 param)
Sets a UINT16 settings value.
FREERDP_API INT16 freerdp_settings_get_int16(const rdpSettings *settings, FreeRDP_Settings_Keys_Int16 id)
Returns a INT16 settings value.
FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL param)
Sets a BOOL settings value.
FREERDP_API const char * freerdp_settings_get_name_for_key(SSIZE_T key)
Returns the type name for a key.