Files
LanMountainDesktop/LanMountainDesktop.Tests/InfoRecommendationHostCornerRadiusTests.cs

75 lines
2.6 KiB
C#
Raw Normal View History

2026-03-20 22:37:37 +08:00
using System.Collections.Generic;
using LanMountainDesktop.Appearance;
using LanMountainDesktop.ComponentSystem;
using LanMountainDesktop.Host.Abstractions;
using LanMountainDesktop.Views.Components;
using Xunit;
namespace LanMountainDesktop.Tests;
public sealed class InfoRecommendationHostCornerRadiusTests
{
private static readonly string[] WideInfoComponentIds =
[
BuiltInComponentIds.DesktopDailyPoetry,
BuiltInComponentIds.DesktopDailyArtwork,
BuiltInComponentIds.DesktopDailyWord,
BuiltInComponentIds.DesktopCnrDailyNews,
BuiltInComponentIds.DesktopIfengNews,
BuiltInComponentIds.DesktopBilibiliHotSearch,
BuiltInComponentIds.DesktopBaiduHotSearch,
BuiltInComponentIds.DesktopStcn24Forum
];
[Theory]
[InlineData(80d)]
[InlineData(120d)]
[InlineData(160d)]
public void InfoHostRegistrations_ResolveToTheUnifiedLgBaseline(double cellSize)
{
var registry = new DesktopComponentRuntimeRegistry(
ComponentRegistry.CreateDefault(),
DesktopComponentRuntimeRegistry.GetDefaultRegistrations());
foreach (var componentId in WideInfoComponentIds)
{
AssertResolved(registry, componentId, cellSize);
}
AssertResolved(registry, BuiltInComponentIds.DesktopDailyWord2x2, cellSize);
}
private static void AssertResolved(
DesktopComponentRuntimeRegistry registry,
string componentId,
double cellSize)
{
Assert.True(
registry.TryGetDescriptor(componentId, out var descriptor),
$"Missing runtime registration for '{componentId}'.");
2026-04-08 00:55:10 +08:00
var sharp = descriptor.ResolveCornerRadius(CreateChromeContext(componentId, cellSize, "Sharp"));
var balanced = descriptor.ResolveCornerRadius(CreateChromeContext(componentId, cellSize, "Balanced"));
var rounded = descriptor.ResolveCornerRadius(CreateChromeContext(componentId, cellSize, "Rounded"));
var open = descriptor.ResolveCornerRadius(CreateChromeContext(componentId, cellSize, "Open"));
2026-03-20 22:37:37 +08:00
2026-04-08 00:55:10 +08:00
// All info widgets should resolve to the Component token in the new system
Assert.Equal(20d, sharp, 3);
Assert.Equal(24d, balanced, 3);
Assert.Equal(28d, rounded, 3);
Assert.Equal(32d, open, 3);
2026-03-20 22:37:37 +08:00
}
private static ComponentChromeContext CreateChromeContext(
string componentId,
double cellSize,
2026-04-08 00:55:10 +08:00
string style)
2026-03-20 22:37:37 +08:00
{
return new ComponentChromeContext(
componentId,
null,
cellSize,
2026-04-08 00:55:10 +08:00
AppearanceCornerRadiusTokenFactory.Create(style));
2026-03-20 22:37:37 +08:00
}
}