Skip to content

Commit b50f0db

Browse files
authored
gui: fix Linux portal dialog response handling (#70)
1 parent e91e5f3 commit b50f0db

3 files changed

Lines changed: 325 additions & 77 deletions

File tree

nativebridge/_linux_backend_test.v

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
module nativebridge
22

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+
314
fn test_linux_filter_arg_builds_patterns() {
415
filter := linux_filter_arg(['png', ' jpg ', '', 'txt'])
516
assert filter == '*.png *.jpg *.txt'
@@ -59,3 +70,37 @@ fn test_linux_print_capability_warnings_include_requested_options() {
5970
})
6071
assert warnings.len >= 5
6172
}
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

Comments
 (0)