Forge
csharpdeeb25a2
1using CascadeIDE.Cockpit.Composition.HostSurface;
2using CascadeIDE.Cockpit.Composition.Shell;
3using CascadeIDE.Models;
4using CascadeIDE.Services.Presentation;
5using Xunit;
6
7using CascadeIDE.Features.Agent.Environment;
8
9namespace CascadeIDE.Tests;
10
11public sealed class MainWindowHostSurfaceCompositorTests
12{
13 private static PresentationGrammarTokens DefaultGrammar() =>
14 PresentationGrammarTokens.FromSettings("()", " ", "+", "P", "F", "M");
15
16 [Fact]
17 public void WhenPfdColumnVisible_IncludesSolutionExplorerInstrumentInPfdSlot()
18 {
19 var parse = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
20 Assert.True(parse.IsSuccess);
21
22 var frame = MainWindowHostSurfaceCompositor.ComposeFrame(
23 new MainWindowShellSurfaceCompositionInput(
24 parse,
25 IntentSolutionExplorerVisible: true,
26 IntentChatPanelExpanded: false,
27 SuppressPfdColumnForPfdHostWindow: false,
28 SuppressMfdColumnForMfdHostWindow: false,
29 ExpandedMfdWidthPixels: 300,
30 CollapsedMfdWidthPixels: 12,
31 DisplaySettings: new DisplaySettings(),
32 SafetyLevel: AgentSafetyLevel.Confirm));
33
34 Assert.True(frame.Shell.PfdSurfaceVisible);
35 Assert.Single(frame.Instruments);
36 Assert.Equal(CockpitStandardInstrumentIds.SolutionExplorerTree, frame.Instruments[0].InstrumentId);
37 Assert.Equal(CockpitSlotIds.Pfd, frame.Instruments[0].SlotId);
38 }
39
40 [Fact]
41 public void WhenPfdColumnHidden_NoInstruments()
42 {
43 var parse = PresentationParser.Parse("(F) (M)", DefaultGrammar());
44 Assert.True(parse.IsSuccess);
45
46 var frame = MainWindowHostSurfaceCompositor.ComposeFrame(
47 new MainWindowShellSurfaceCompositionInput(
48 parse,
49 IntentSolutionExplorerVisible: false,
50 IntentChatPanelExpanded: false,
51 SuppressPfdColumnForPfdHostWindow: false,
52 SuppressMfdColumnForMfdHostWindow: false,
53 ExpandedMfdWidthPixels: 300,
54 CollapsedMfdWidthPixels: 12,
55 DisplaySettings: new DisplaySettings(),
56 SafetyLevel: AgentSafetyLevel.Confirm));
57
58 Assert.False(frame.Shell.PfdSurfaceVisible);
59 Assert.Empty(frame.Instruments);
60 }
61
62 [Fact]
63 public void UserPlacementRule_OverridesDefaultInstrumentForPfdSlot()
64 {
65 var parse = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
66 Assert.True(parse.IsSuccess);
67
68 var display = new DisplaySettings
69 {
70 Instruments = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
71 {
72 [InstrumentRoutingSlotKeys.PfdPrimary] = "workspace_map"
73 }
74 };
75
76 var frame = MainWindowHostSurfaceCompositor.ComposeFrame(
77 new MainWindowShellSurfaceCompositionInput(
78 parse,
79 IntentSolutionExplorerVisible: true,
80 IntentChatPanelExpanded: false,
81 SuppressPfdColumnForPfdHostWindow: false,
82 SuppressMfdColumnForMfdHostWindow: false,
83 ExpandedMfdWidthPixels: 300,
84 CollapsedMfdWidthPixels: 12,
85 DisplaySettings: display,
86 SafetyLevel: AgentSafetyLevel.Confirm));
87
88 Assert.True(frame.Shell.PfdSurfaceVisible);
89 Assert.Single(frame.Instruments);
90 Assert.Equal(CockpitStandardInstrumentIds.WorkspaceNavigationMap, frame.Instruments[0].InstrumentId);
91 Assert.Equal(CockpitSlotIds.Pfd, frame.Instruments[0].SlotId);
92 }
93}
94
View only · write via MCP/CIDE