File tests/misc/menus_filetypes.c changed (mode: 100644) (index af60a2fbd..c6279af79) |
5 |
5 |
|
|
6 |
6 |
#include "../../src/compat/fs_limits.h" |
#include "../../src/compat/fs_limits.h" |
7 |
7 |
#include "../../src/engine/keys.h" |
#include "../../src/engine/keys.h" |
|
8 |
|
#include "../../src/engine/mode.h" |
|
9 |
|
#include "../../src/modes/cmdline.h" |
|
10 |
|
#include "../../src/modes/menu.h" |
8 |
11 |
#include "../../src/modes/modes.h" |
#include "../../src/modes/modes.h" |
9 |
12 |
#include "../../src/modes/wk.h" |
#include "../../src/modes/wk.h" |
10 |
13 |
#include "../../src/ui/ui.h" |
#include "../../src/ui/ui.h" |
11 |
14 |
#include "../../src/utils/fs.h" |
#include "../../src/utils/fs.h" |
|
15 |
|
#include "../../src/utils/matchers.h" |
12 |
16 |
#include "../../src/cmd_core.h" |
#include "../../src/cmd_core.h" |
13 |
17 |
#include "../../src/filelist.h" |
#include "../../src/filelist.h" |
14 |
18 |
#include "../../src/filetype.h" |
#include "../../src/filetype.h" |
|
16 |
20 |
|
|
17 |
21 |
#include "utils.h" |
#include "utils.h" |
18 |
22 |
|
|
|
23 |
|
static line_stats_t *stats; |
19 |
24 |
static char cwd[PATH_MAX + 1]; |
static char cwd[PATH_MAX + 1]; |
20 |
25 |
|
|
21 |
26 |
SETUP_ONCE() |
SETUP_ONCE() |
22 |
27 |
{ |
{ |
|
28 |
|
stats = get_line_stats(); |
|
29 |
|
|
23 |
30 |
assert_non_null(get_cwd(cwd, sizeof(cwd))); |
assert_non_null(get_cwd(cwd, sizeof(cwd))); |
24 |
31 |
|
|
25 |
32 |
ft_init(NULL); |
ft_init(NULL); |
26 |
|
ft_reset(0); |
|
27 |
33 |
} |
} |
28 |
34 |
|
|
29 |
35 |
SETUP() |
SETUP() |
|
... |
... |
SETUP() |
40 |
46 |
populate_dir_list(&lwin, 0); |
populate_dir_list(&lwin, 0); |
41 |
47 |
|
|
42 |
48 |
curr_stats.load_stage = -1; |
curr_stats.load_stage = -1; |
43 |
|
curr_stats.save_msg = 0; |
|
|
49 |
|
|
|
50 |
|
ft_reset(0); |
44 |
51 |
} |
} |
45 |
52 |
|
|
46 |
53 |
TEARDOWN() |
TEARDOWN() |
|
... |
... |
TEARDOWN() |
55 |
62 |
curr_stats.load_stage = 0; |
curr_stats.load_stage = 0; |
56 |
63 |
} |
} |
57 |
64 |
|
|
58 |
|
TEST(enter_loads_selected_colorscheme) |
|
|
65 |
|
TEST(opening_a_directory_works) |
|
66 |
|
{ |
|
67 |
|
assert_success(exec_commands("file", &lwin, CIT_COMMAND)); |
|
68 |
|
|
|
69 |
|
(void)vle_keys_exec(WK_CR); |
|
70 |
|
|
|
71 |
|
char new_path[PATH_MAX + 1]; |
|
72 |
|
make_abs_path(new_path, sizeof(new_path), TEST_DATA_PATH, "color-schemes", |
|
73 |
|
cwd); |
|
74 |
|
assert_true(paths_are_same(lwin.curr_dir, new_path)); |
|
75 |
|
|
|
76 |
|
(void)vle_keys_exec(WK_ESC); |
|
77 |
|
} |
|
78 |
|
|
|
79 |
|
TEST(no_menu_for_fake_entry) |
|
80 |
|
{ |
|
81 |
|
get_current_entry(&lwin)->name[0] = '\0'; |
|
82 |
|
assert_success(exec_commands("file", &lwin, CIT_COMMAND)); |
|
83 |
|
assert_true(vle_mode_is(NORMAL_MODE)); |
|
84 |
|
} |
|
85 |
|
|
|
86 |
|
TEST(c_key_is_handled) |
|
87 |
|
{ |
|
88 |
|
assert_success(exec_commands("file", &lwin, CIT_COMMAND)); |
|
89 |
|
|
|
90 |
|
(void)vle_keys_exec(WK_c); |
|
91 |
|
assert_true(vle_mode_is(CMDLINE_MODE)); |
|
92 |
|
|
|
93 |
|
assert_wstring_equal(L"!vifm", stats->line); |
|
94 |
|
|
|
95 |
|
(void)vle_keys_exec(WK_ESC); |
|
96 |
|
} |
|
97 |
|
|
|
98 |
|
TEST(unknown_key_is_ignored) |
59 |
99 |
{ |
{ |
60 |
100 |
assert_success(exec_commands("file", &lwin, CIT_COMMAND)); |
assert_success(exec_commands("file", &lwin, CIT_COMMAND)); |
61 |
101 |
|
|
|
102 |
|
(void)vle_keys_exec(WK_t); |
62 |
103 |
(void)vle_keys_exec(WK_CR); |
(void)vle_keys_exec(WK_CR); |
63 |
104 |
|
|
64 |
105 |
char new_path[PATH_MAX + 1]; |
char new_path[PATH_MAX + 1]; |
|
... |
... |
TEST(enter_loads_selected_colorscheme) |
69 |
110 |
(void)vle_keys_exec(WK_ESC); |
(void)vle_keys_exec(WK_ESC); |
70 |
111 |
} |
} |
71 |
112 |
|
|
|
113 |
|
TEST(pseudo_entry_is_always_present_for_directories) |
|
114 |
|
{ |
|
115 |
|
char *error; |
|
116 |
|
matchers_t *ms = matchers_alloc("{bla-*/}", 0, 1, "", &error); |
|
117 |
|
assert_non_null(ms); |
|
118 |
|
|
|
119 |
|
ft_set_programs(ms, "abc-run %c", 0, 0); |
|
120 |
|
|
|
121 |
|
assert_success(exec_commands("filetype bla-dir/", &lwin, CIT_COMMAND)); |
|
122 |
|
|
|
123 |
|
assert_int_equal(2, menu_get_current()->len); |
|
124 |
|
assert_string_equal("[present] [Enter directory] " VIFM_PSEUDO_CMD, |
|
125 |
|
menu_get_current()->items[0]); |
|
126 |
|
assert_string_equal("[present] abc-run %c", |
|
127 |
|
menu_get_current()->items[1]); |
|
128 |
|
|
|
129 |
|
(void)vle_keys_exec(WK_ESC); |
|
130 |
|
} |
|
131 |
|
|
|
132 |
|
TEST(no_menu_if_no_handlers) |
|
133 |
|
{ |
|
134 |
|
assert_failure(exec_commands("filetype bla-file", &lwin, CIT_COMMAND)); |
|
135 |
|
} |
|
136 |
|
|
|
137 |
|
TEST(filetypes_menu) |
|
138 |
|
{ |
|
139 |
|
char *error; |
|
140 |
|
matchers_t *ms = matchers_alloc("{a,b,c}", 0, 1, "", &error); |
|
141 |
|
assert_non_null(ms); |
|
142 |
|
|
|
143 |
|
ft_set_programs(ms, "abc-run %c", 0, 0); |
|
144 |
|
|
|
145 |
|
assert_success(exec_commands("filetype b", &lwin, CIT_COMMAND)); |
|
146 |
|
|
|
147 |
|
assert_int_equal(1, menu_get_current()->len); |
|
148 |
|
assert_string_equal("[present] abc-run %c", menu_get_current()->items[0]); |
|
149 |
|
|
|
150 |
|
(void)vle_keys_exec(WK_ESC); |
|
151 |
|
} |
|
152 |
|
|
|
153 |
|
TEST(fileviewers_menu) |
|
154 |
|
{ |
|
155 |
|
char *error; |
|
156 |
|
matchers_t *ms = matchers_alloc("{a,b,c}", 0, 1, "", &error); |
|
157 |
|
assert_non_null(ms); |
|
158 |
|
|
|
159 |
|
ft_set_viewers(ms, "abc-view %c"); |
|
160 |
|
|
|
161 |
|
assert_success(exec_commands("fileviewer c", &lwin, CIT_COMMAND)); |
|
162 |
|
|
|
163 |
|
assert_int_equal(1, menu_get_current()->len); |
|
164 |
|
assert_string_equal("[present] abc-view %c", menu_get_current()->items[0]); |
|
165 |
|
|
|
166 |
|
(void)vle_keys_exec(WK_ESC); |
|
167 |
|
} |
|
168 |
|
|
72 |
169 |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
73 |
170 |
/* vim: set cinoptions+=t0 : */ |
/* vim: set cinoptions+=t0 : */ |