|
1 | 1 | module nativebridge |
2 | 2 |
|
| 3 | +$if linux { |
| 4 | + #flag linux -DGUI_PORTAL_TESTING |
| 5 | + #include "@VMODROOT/nativebridge/portal_linux_test.h" |
| 6 | + |
| 7 | + fn C.gui_portal_test_build_handle_path_equals(&char, &char, &char) int |
| 8 | + fn C.gui_portal_test_build_handle_path_rejects_empty_sender() int |
| 9 | + fn C.gui_portal_test_parse_reply_handle_equals(&char, &char) int |
| 10 | + fn C.gui_portal_test_parse_reply_handle_rejects_empty_reply() int |
| 11 | + fn C.gui_portal_test_parse_reply_handle_rejects_string() int |
| 12 | +} |
| 13 | + |
3 | 14 | fn test_linux_filter_arg_builds_patterns() { |
4 | 15 | filter := linux_filter_arg(['png', ' jpg ', '', 'txt']) |
5 | 16 | assert filter == '*.png *.jpg *.txt' |
@@ -59,3 +70,37 @@ fn test_linux_print_capability_warnings_include_requested_options() { |
59 | 70 | }) |
60 | 71 | assert warnings.len >= 5 |
61 | 72 | } |
| 73 | + |
| 74 | +fn test_portal_handle_path_removes_unique_name_leading_colon() { |
| 75 | + $if linux { |
| 76 | + assert C.gui_portal_test_build_handle_path_equals(c':1.244', c'gui_1783082018_0', |
| 77 | + c'/org/freedesktop/portal/desktop/request/1_244/gui_1783082018_0') == 1 |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +fn test_portal_handle_path_sanitizes_dots_without_extra_prefix() { |
| 82 | + $if linux { |
| 83 | + assert C.gui_portal_test_build_handle_path_equals(c'1.244', c'gui_token', |
| 84 | + c'/org/freedesktop/portal/desktop/request/1_244/gui_token') == 1 |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +fn test_portal_handle_path_rejects_empty_sender() { |
| 89 | + $if linux { |
| 90 | + assert C.gui_portal_test_build_handle_path_rejects_empty_sender() == 1 |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +fn test_portal_reply_handle_parses_object_path() { |
| 95 | + $if linux { |
| 96 | + handle := '/org/freedesktop/portal/desktop/request/1_244/gui_token' |
| 97 | + assert C.gui_portal_test_parse_reply_handle_equals(handle.str, handle.str) == 1 |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +fn test_portal_reply_handle_rejects_missing_or_wrong_type() { |
| 102 | + $if linux { |
| 103 | + assert C.gui_portal_test_parse_reply_handle_rejects_empty_reply() == 1 |
| 104 | + assert C.gui_portal_test_parse_reply_handle_rejects_string() == 1 |
| 105 | + } |
| 106 | +} |
0 commit comments