aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/plugins/unit/plugin_tests.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-09-30 18:04:40 +0200
committerGitHub <noreply@github.com>2024-09-30 18:04:40 +0200
commit9f1e38f9fa6efd166f5205eaa8603d6b05a68b2b (patch)
tree3e41bdf65e4bb83fc08f3ad23f913630a97a3d97 /zellij-server/src/plugins/unit/plugin_tests.rs
parentdocs(changelog): background plugins (diff)
downloadsl0ppij-9f1e38f9fa6efd166f5205eaa8603d6b05a68b2b.tar.gz
sl0ppij-9f1e38f9fa6efd166f5205eaa8603d6b05a68b2b.tar.xz
sl0ppij-9f1e38f9fa6efd166f5205eaa8603d6b05a68b2b.zip
feat(ui): built-in plugin manager (#3633)
* add plugin list to session info * feat(plugins): new_plugin and reload_plugin API commands * feat(plugins): built-in plugin manager * style(fmt): rustfmt * update plugins
Diffstat (limited to 'zellij-server/src/plugins/unit/plugin_tests.rs')
-rw-r--r--zellij-server/src/plugins/unit/plugin_tests.rs348
1 files changed, 245 insertions, 103 deletions
diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs
index 690ef516..630ae70b 100644
--- a/zellij-server/src/plugins/unit/plugin_tests.rs
+++ b/zellij-server/src/plugins/unit/plugin_tests.rs
@@ -708,7 +708,7 @@ pub fn load_new_plugin_from_hd() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -788,7 +788,7 @@ pub fn load_new_plugin_with_plugin_alias() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -864,7 +864,7 @@ pub fn plugin_workers() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -944,7 +944,7 @@ pub fn plugin_workers_persist_state() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1034,7 +1034,7 @@ pub fn can_subscribe_to_hd_events() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1112,7 +1112,7 @@ pub fn switch_to_mode_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1184,7 +1184,7 @@ pub fn switch_to_mode_plugin_command_permission_denied() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1256,7 +1256,7 @@ pub fn new_tabs_with_layout_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1342,7 +1342,7 @@ pub fn new_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1414,7 +1414,7 @@ pub fn go_to_next_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1485,7 +1485,7 @@ pub fn go_to_previous_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1556,7 +1556,7 @@ pub fn resize_focused_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1627,7 +1627,7 @@ pub fn resize_focused_pane_with_direction_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1698,7 +1698,7 @@ pub fn focus_next_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1769,7 +1769,7 @@ pub fn focus_previous_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1840,7 +1840,7 @@ pub fn move_focus_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1911,7 +1911,7 @@ pub fn move_focus_or_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -1982,7 +1982,7 @@ pub fn edit_scrollback_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2053,7 +2053,7 @@ pub fn write_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2124,7 +2124,7 @@ pub fn write_chars_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2195,7 +2195,7 @@ pub fn toggle_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2266,7 +2266,7 @@ pub fn move_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2337,7 +2337,7 @@ pub fn move_pane_with_direction_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2409,7 +2409,7 @@ pub fn clear_screen_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2481,7 +2481,7 @@ pub fn scroll_up_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2552,7 +2552,7 @@ pub fn scroll_down_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2623,7 +2623,7 @@ pub fn scroll_to_top_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2694,7 +2694,7 @@ pub fn scroll_to_bottom_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2765,7 +2765,7 @@ pub fn page_scroll_up_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2836,7 +2836,7 @@ pub fn page_scroll_down_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2907,7 +2907,7 @@ pub fn toggle_focus_fullscreen_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -2978,7 +2978,7 @@ pub fn toggle_pane_frames_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3049,7 +3049,7 @@ pub fn toggle_pane_embed_or_eject_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3120,7 +3120,7 @@ pub fn undo_rename_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3191,7 +3191,7 @@ pub fn close_focus_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3262,7 +3262,7 @@ pub fn toggle_active_tab_sync_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3333,7 +3333,7 @@ pub fn close_focused_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3404,7 +3404,7 @@ pub fn undo_rename_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3475,7 +3475,7 @@ pub fn previous_swap_layout_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3546,7 +3546,7 @@ pub fn next_swap_layout_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3617,7 +3617,7 @@ pub fn go_to_tab_name_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3688,7 +3688,7 @@ pub fn focus_or_create_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3759,7 +3759,7 @@ pub fn go_to_tab() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3830,7 +3830,7 @@ pub fn start_or_reload_plugin() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3908,7 +3908,7 @@ pub fn quit_zellij_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -3986,7 +3986,7 @@ pub fn detach_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4064,7 +4064,7 @@ pub fn open_file_floating_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4146,7 +4146,7 @@ pub fn open_file_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4229,7 +4229,7 @@ pub fn open_file_with_line_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4311,7 +4311,7 @@ pub fn open_file_with_line_floating_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4393,7 +4393,7 @@ pub fn open_terminal_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4471,7 +4471,7 @@ pub fn open_terminal_floating_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4549,7 +4549,7 @@ pub fn open_command_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4627,7 +4627,7 @@ pub fn open_command_pane_floating_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4698,7 +4698,7 @@ pub fn switch_to_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4769,7 +4769,7 @@ pub fn hide_self_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4839,7 +4839,7 @@ pub fn show_self_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4910,7 +4910,7 @@ pub fn close_terminal_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -4981,7 +4981,7 @@ pub fn close_plugin_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5052,7 +5052,7 @@ pub fn focus_terminal_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5123,7 +5123,7 @@ pub fn focus_plugin_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5194,7 +5194,7 @@ pub fn rename_terminal_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5265,7 +5265,7 @@ pub fn rename_plugin_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5336,7 +5336,7 @@ pub fn rename_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5416,7 +5416,7 @@ pub fn send_configuration_to_plugins() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5484,7 +5484,7 @@ pub fn request_plugin_permissions() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5576,7 +5576,7 @@ pub fn granted_permission_request_result() {
false,
plugin_title,
run_plugin.clone(),
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5667,7 +5667,7 @@ pub fn denied_permission_request_result() {
false,
plugin_title,
run_plugin.clone(),
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5738,7 +5738,7 @@ pub fn run_command_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5816,7 +5816,7 @@ pub fn run_command_with_env_vars_and_cwd_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5894,7 +5894,7 @@ pub fn web_request_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -5965,7 +5965,7 @@ pub fn unblock_input_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6047,7 +6047,7 @@ pub fn block_input_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6137,7 +6137,7 @@ pub fn pipe_output_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6220,7 +6220,7 @@ pub fn pipe_message_to_plugin_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6314,7 +6314,7 @@ pub fn switch_session_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6395,7 +6395,7 @@ pub fn switch_session_with_layout_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6476,7 +6476,7 @@ pub fn switch_session_with_layout_and_cwd_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6557,7 +6557,7 @@ pub fn disconnect_other_clients_plugins_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6638,7 +6638,7 @@ pub fn reconfigure_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6723,7 +6723,7 @@ pub fn run_plugin_in_specific_cwd() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6797,7 +6797,7 @@ pub fn hide_pane_with_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6868,7 +6868,7 @@ pub fn show_pane_with_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -6946,7 +6946,7 @@ pub fn open_command_pane_background_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7021,7 +7021,7 @@ pub fn rerun_command_pane_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7092,7 +7092,7 @@ pub fn resize_pane_with_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7163,7 +7163,7 @@ pub fn edit_scrollback_for_pane_with_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7234,7 +7234,7 @@ pub fn write_to_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7305,7 +7305,7 @@ pub fn write_chars_to_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7376,7 +7376,7 @@ pub fn move_pane_with_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7447,7 +7447,7 @@ pub fn move_pane_with_pane_id_in_direction_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7518,7 +7518,7 @@ pub fn clear_screen_for_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7589,7 +7589,7 @@ pub fn scroll_up_in_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7660,7 +7660,7 @@ pub fn scroll_down_in_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7731,7 +7731,7 @@ pub fn scroll_to_top_in_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7802,7 +7802,7 @@ pub fn scroll_to_bottom_in_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7873,7 +7873,7 @@ pub fn page_scroll_up_in_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -7944,7 +7944,7 @@ pub fn page_scroll_down_in_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -8015,7 +8015,7 @@ pub fn toggle_pane_id_fullscreen_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -8086,7 +8086,7 @@ pub fn toggle_pane_embed_or_eject_for_pane_id_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -8157,7 +8157,7 @@ pub fn close_tab_with_index_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -8228,7 +8228,7 @@ pub fn break_panes_to_new_tab_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -8299,7 +8299,7 @@ pub fn break_panes_to_tab_with_index_plugin_command() {
false,
plugin_title,
run_plugin,
- tab_index,
+ Some(tab_index),
None,
client_id,
size,
@@ -8328,3 +8328,145 @@ pub fn break_panes_to_tab_with_index_plugin_command() {
.clone();
assert_snapshot!(format!("{:#?}", screen_instruction));
}
+
+#[test]
+#[ignore]
+pub fn reload_plugin_plugin_command() {
+ let temp_folder = tempdir().unwrap(); // placed explicitly in the test scope because its
+ // destructor removes the directory
+ let plugin_host_folder = PathBuf::from(temp_folder.path());
+ let cache_path = plugin_host_folder.join("permissions_test.kdl");
+ let (plugin_thread_sender, screen_receiver, teardown) =
+ create_plugin_thread(Some(plugin_host_folder));
+ let plugin_should_float = Some(false);
+ let plugin_title = Some("test_plugin".to_owned());
+ let run_plugin = RunPluginOrAlias::RunPlugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from(&*PLUGIN_FIXTURE)),
+ configuration: Default::default(),
+ ..Default::default()
+ });
+ let tab_index = 1;
+ let client_id = 1;
+ let size = Size {
+ cols: 121,
+ rows: 20,
+ };
+ let received_screen_instructions = Arc::new(Mutex::new(vec![]));
+ let screen_thread = grant_permissions_and_log_actions_in_thread_naked_variant!(
+ received_screen_instructions,
+ ScreenInstruction::RequestStateUpdateForPlugins, // happens on successful plugin (re)load
+ screen_receiver,
+ 3,
+ &PermissionType::ChangeApplicationState,
+ cache_path,
+ plugin_thread_sender,
+ client_id
+ );
+
+ let _ = plugin_thread_sender.send(PluginInstruction::AddClient(client_id));
+ let _ = plugin_thread_sender.send(PluginInstruction::Load(
+ plugin_should_float,
+ false,
+ plugin_title,
+ run_plugin,
+ Some(tab_index),
+ None,
+ client_id,
+ size,
+ None,
+ false,
+ ));
+ std::thread::sleep(std::time::Duration::from_millis(500));
+ let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
+ None,
+ Some(client_id),
+ Event::Key(KeyWithModifier::new(BareKey::Char('w')).with_alt_modifier()), // this triggers the enent in the fixture plugin
+ )]));
+ screen_thread.join().unwrap(); // this might take a while if the cache is cold
+ teardown();
+ let request_state_update_requests = received_screen_instructions
+ .lock()
+ .unwrap()
+ .iter()
+ .filter(|i| {
+ if let ScreenInstruction::RequestStateUpdateForPlugins = i {
+ true
+ } else {
+ false
+ }
+ })
+ .count();
+ assert_eq!(request_state_update_requests, 3);
+}
+
+#[test]
+#[ignore]
+pub fn load_new_plugin_plugin_command() {
+ let temp_folder = tempdir().unwrap(); // placed explicitly in the test scope because its
+ // destructor removes the directory
+ let plugin_host_folder = PathBuf::from(temp_folder.path());
+ let cache_path = plugin_host_folder.join("permissions_test.kdl");
+ let (plugin_thread_sender, screen_receiver, teardown) =
+ create_plugin_thread(Some(plugin_host_folder));
+ let plugin_should_float = Some(false);
+ let plugin_title = Some("test_plugin".to_owned());
+ let run_plugin = RunPluginOrAlias::RunPlugin(RunPlugin {
+ _allow_exec_host_cmd: false,
+ location: RunPluginLocation::File(PathBuf::from(&*PLUGIN_FIXTURE)),
+ configuration: Default::default(),
+ ..Default::default()
+ });
+ let tab_index = 1;
+ let client_id = 1;
+ let size = Size {
+ cols: 121,
+ rows: 20,
+ };
+ let received_screen_instructions = Arc::new(Mutex::new(vec![]));
+ let screen_thread = grant_permissions_and_log_actions_in_thread_naked_variant!(
+ received_screen_instructions,
+ ScreenInstruction::RequestStateUpdateForPlugins, // happens on successful plugin (re)load
+ screen_receiver,
+ 3,
+ &PermissionType::ChangeApplicationState,
+ cache_path,
+ plugin_thread_sender,
+ client_id
+ );
+
+ let _ = plugin_thread_sender.send(PluginInstruction::AddClient(client_id));
+ let _ = plugin_thread_sender.send(PluginInstruction::Load(
+ plugin_should_float,
+ false,
+ plugin_title,
+ run_plugin,
+ Some(tab_index),
+ None,
+ client_id,
+ size,
+ None,
+ false,
+ ));
+ std::thread::sleep(std::time::Duration::from_millis(500));
+ let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
+ None,
+ Some(client_id),
+ Event::Key(KeyWithModifier::new(BareKey::Char('x')).with_alt_modifier()), // this triggers the enent in the fixture plugin
+ )]));
+ screen_thread.join().unwrap(); // this might take a while if the cache is cold
+ teardown();
+ let request_state_update_requests = received_screen_instructions
+ .lock()
+ .unwrap()
+ .iter()
+ .filter(|i| {
+ if let ScreenInstruction::RequestStateUpdateForPlugins = i {
+ true
+ } else {
+ false
+ }
+ })
+ .count();
+ assert_eq!(request_state_update_requests, 3);
+}