Forge
csharpdeeb25a2
1using CascadeIDE.Cockpit.Cds;
2using CascadeIDE.Models;
3using CascadeIDE.Services.Presentation;
4using Xunit;
5
6namespace CascadeIDE.Tests;
7
8public sealed class CockpitPresentationLayoutPolicyTests
9{
10 private static PresentationGrammarTokens DefaultGrammar() =>
11 PresentationGrammarTokens.FromSettings(
12 brackets: "()",
13 betweenScreens: " ",
14 betweenZones: "+",
15 pfdZoneIdentifier: "P",
16 forwardZoneIdentifier: "F",
17 mfdZoneIdentifier: "M");
18
19 [Fact]
20 public void RequiresPfd_WhenDedicatedMfdSecondScreen_FirstScreenHasP()
21 {
22 var r = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
23 Assert.True(r.IsSuccess);
24 Assert.True(CockpitPresentationLayoutPolicy.RequiresPfdRegionInMainWindow(r));
25 }
26
27 [Fact]
28 public void RequiresMfdInMain_WhenSingleScreenWeightedP_F_M_True()
29 {
30 var r = PresentationParser.Parse("(0.2P+0.3F+0.5M)", DefaultGrammar());
31 Assert.True(r.IsSuccess);
32 Assert.True(CockpitPresentationLayoutPolicy.RequiresMfdRegionInMainWindow(r));
33 }
34
35 [Fact]
36 public void RequiresMfdInMain_WhenDedicatedSecondScreen_False()
37 {
38 var r = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
39 Assert.True(r.IsSuccess);
40 Assert.False(CockpitPresentationLayoutPolicy.RequiresMfdRegionInMainWindow(r));
41 }
42
43 [Fact]
44 public void CoercePfdRegion_FalseWhenPfdRequired_BecomesTrue()
45 {
46 var r = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
47 Assert.True(CockpitPresentationLayoutPolicy.CoercePfdRegionExpanded(r, false));
48 }
49
50 [Fact]
51 public void CoerceMfdRegion_FalseWhenMOnFirstScreen_BecomesTrue()
52 {
53 var r = PresentationParser.Parse("(P+F+M)", DefaultGrammar());
54 Assert.True(r.IsSuccess);
55 Assert.True(CockpitPresentationLayoutPolicy.CoerceMfdRegionExpanded(r, false));
56 }
57
58 [Fact]
59 public void CoerceMfdRegion_FalseWhenNoMOnFirstScreen_Unchanged()
60 {
61 var r = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
62 Assert.False(CockpitPresentationLayoutPolicy.CoerceMfdRegionExpanded(r, false));
63 }
64
65 [Fact]
66 public void RequiresPfdInMain_compact_tier_always_false()
67 {
68 var r = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
69 Assert.False(CockpitPresentationLayoutPolicy.RequiresPfdRegionInMainWindow(r, PresentationTierKind.Compact));
70 Assert.False(CockpitPresentationLayoutPolicy.RequiresMfdRegionInMainWindow(r, PresentationTierKind.Compact));
71 }
72
73 [Fact]
74 public void RequiresPfdInMain_WhenTripleP_F_M_FalseOnForwardScreen()
75 {
76 var r = PresentationParser.Parse("(P) (F) (M)", DefaultGrammar());
77 Assert.True(r.IsSuccess);
78 Assert.False(CockpitPresentationLayoutPolicy.RequiresPfdRegionInMainWindow(r));
79 Assert.False(CockpitPresentationLayoutPolicy.RequiresMfdRegionInMainWindow(r));
80 }
81}
82
View only · write via MCP/CIDE