Forge
csharpdeeb25a2
1#nullable enable
2
3using CascadeIDE.Views.Chat.Skia;
4using Xunit;
5
6namespace CascadeIDE.Tests;
7
8public sealed class SkiaChatFeedLayoutTests
9{
10 [Fact]
11 public void Feed_measure_height_has_no_bubble_padding()
12 {
13 var ctx = new SkiaChatMeasureContext(60, 480);
14 var body = "Line one\nLine two";
15 var feedSpec = new SkiaChatBubbleSpec(
16 "Агент",
17 body,
18 Footer: null,
19 SkiaChatBubbleKind.Feed,
20 SkiaBubbleFillRole.MessageAssistant,
21 SkiaChatBodyTone.Normal,
22 IsPending: false,
23 IsSelected: false,
24 StartsBranch: false,
25 MessageIndex: 0,
26 Padding: 0,
27 TitleHeight: 16,
28 LineHeight: 15);
29
30 var bubbleSpec = feedSpec with { Kind = SkiaChatBubbleKind.Standard, Padding = 10 };
31
32 var feedMetrics = SkiaChatBubbleRenderer.Measure(ctx, feedSpec);
33 var bubbleMetrics = SkiaChatBubbleRenderer.Measure(ctx, bubbleSpec);
34
35 var feedHeight = SkiaChatBubbleRenderer.MeasureHeight(feedSpec, feedMetrics);
36 var bubbleHeight = SkiaChatBubbleRenderer.MeasureHeight(bubbleSpec, bubbleMetrics);
37
38 Assert.True(feedHeight < bubbleHeight);
39 }
40
41 [Fact]
42 public void Body_column_shifts_right_when_role_rail_shown()
43 {
44 var layout = SkiaChatFeedLayout.For(forwardHost: false);
45 var without = layout.BodyColumn(contentLeft: 40f, contentWidth: 400f, includeRoleRail: false);
46 var with = layout.BodyColumn(contentLeft: 40f, contentWidth: 400f, includeRoleRail: true);
47
48 Assert.Equal(40f, without.Left);
49 Assert.Equal(400f, without.Width);
50 Assert.Equal(40f + layout.RoleRailWidth, with.Left);
51 Assert.Equal(400f - layout.RoleRailWidth, with.Width);
52 }
53
54 [Fact]
55 public void Slash_text_column_reserves_role_rail_and_icon()
56 {
57 var layout = SkiaChatFeedLayout.For(forwardHost: true);
58 var column = layout.SlashTextColumn(contentLeft: 0f, contentWidth: 320f);
59
60 Assert.True(column.Left > layout.RoleRailWidth);
61 Assert.True(column.Width < 320f - layout.RoleRailWidth - layout.SlashIconReserve);
62 }
63}
64
View only · write via MCP/CIDE