1use gpui::{Entity, TestAppContext, WindowHandle};
2use project::Project;
3use settings::SettingsStore;
4use terminal_view::terminal_panel::TerminalPanel;
5use workspace::Workspace;
6
7use crate::{debugger_panel::DebugPanel, session::DebugSession};
8
9mod attach_modal;
10mod console;
11mod debugger_panel;
12mod module_list;
13mod stack_frame_list;
14mod variable_list;
15
16pub fn init_test(cx: &mut gpui::TestAppContext) {
17 if std::env::var("RUST_LOG").is_ok() {
18 env_logger::try_init().ok();
19 }
20
21 cx.update(|cx| {
22 let settings = SettingsStore::test(cx);
23 cx.set_global(settings);
24 terminal_view::init(cx);
25 theme::init(theme::LoadThemes::JustBase, cx);
26 command_palette_hooks::init(cx);
27 language::init(cx);
28 workspace::init_settings(cx);
29 Project::init_settings(cx);
30 editor::init(cx);
31 crate::init(cx);
32 });
33}
34
35pub async fn init_test_workspace(
36 project: &Entity<Project>,
37 cx: &mut TestAppContext,
38) -> WindowHandle<Workspace> {
39 let workspace_handle =
40 cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx));
41
42 let debugger_panel = workspace_handle
43 .update(cx, |_, window, cx| cx.spawn_in(window, DebugPanel::load))
44 .unwrap()
45 .await
46 .expect("Failed to load debug panel");
47
48 let terminal_panel = workspace_handle
49 .update(cx, |_, window, cx| cx.spawn_in(window, TerminalPanel::load))
50 .unwrap()
51 .await
52 .expect("Failed to load terminal panel");
53
54 workspace_handle
55 .update(cx, |workspace, window, cx| {
56 workspace.add_panel(debugger_panel, window, cx);
57 workspace.add_panel(terminal_panel, window, cx);
58 })
59 .unwrap();
60 workspace_handle
61}
62
63pub fn active_debug_session_panel(
64 workspace: WindowHandle<Workspace>,
65 cx: &mut TestAppContext,
66) -> Entity<DebugSession> {
67 workspace
68 .update(cx, |workspace, _window, cx| {
69 let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
70 debug_panel
71 .update(cx, |this, cx| this.active_session(cx))
72 .unwrap()
73 })
74 .unwrap()
75}