2026-03-20 22:37:37 +08:00
|
|
|
using System;
|
|
|
|
|
using Avalonia;
|
|
|
|
|
using LanMountainDesktop.Appearance;
|
|
|
|
|
using LanMountainDesktop.ComponentSystem;
|
|
|
|
|
using LanMountainDesktop.Host.Abstractions;
|
|
|
|
|
using LanMountainDesktop.Views.Components;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace LanMountainDesktop.Tests;
|
|
|
|
|
|
|
|
|
|
public sealed class BuiltInDesktopHostCornerRadiusBaselineTests
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
2026-04-08 00:55:10 +08:00
|
|
|
[InlineData(80d, "Sharp")]
|
|
|
|
|
[InlineData(120d, "Balanced")]
|
|
|
|
|
[InlineData(160d, "Rounded")]
|
|
|
|
|
public void BuiltInDesktopHosts_ResolveToTheUnifiedLgBaseline(double cellSize, string style)
|
2026-03-20 22:37:37 +08:00
|
|
|
{
|
|
|
|
|
var registry = new DesktopComponentRuntimeRegistry(
|
|
|
|
|
ComponentRegistry.CreateDefault(),
|
|
|
|
|
DesktopComponentRuntimeRegistry.GetDefaultRegistrations());
|
2026-04-08 00:55:10 +08:00
|
|
|
var expected = AppearanceCornerRadiusTokenFactory.Create(style).Component.TopLeft;
|
2026-03-20 22:37:37 +08:00
|
|
|
|
|
|
|
|
foreach (var descriptor in registry.GetDesktopComponents())
|
|
|
|
|
{
|
2026-04-08 00:55:10 +08:00
|
|
|
var resolved = descriptor.ResolveCornerRadius(CreateChromeContext(descriptor.Definition.Id, cellSize, style));
|
2026-03-20 22:37:37 +08:00
|
|
|
Assert.Equal(expected, resolved, 3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|