mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-29 07:16:33 +08:00
63 lines
3.3 KiB
C#
63 lines
3.3 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace AtomUI.Desktop.Controls.Tests.ScrollViewers;
|
|
|
|
public class ScrollViewerThemeContractTests
|
|
{
|
|
[Fact]
|
|
public void Lite_And_AutoHide_Modes_Keep_Scroll_Content_Behind_ScrollBars()
|
|
{
|
|
var source = ReadRepoFile("src/AtomUI.Desktop.Controls/ScrollViewer/Themes/ScrollViewerTheme.axaml");
|
|
|
|
source.ShouldContain("<atom:ScopeAwareOverlayLayerPanel Name=\"PART_ContentHost\"");
|
|
source.ShouldContain("<Grid Name=\"PART_ScrollLayout\"");
|
|
source.ShouldContain("Name=\"PART_ContentHost\"");
|
|
source.ShouldContain("Name=\"PART_ScrollContentHost\"");
|
|
source.ShouldContain("Selector=\"^[AllowAutoHide=True] /template/ Panel#PART_ScrollContentHost\"");
|
|
source.ShouldContain("Selector=\"^[IsLiteMode=True] /template/ Panel#PART_ScrollContentHost\"");
|
|
source.ShouldContain("<Setter Property=\"Grid.ColumnSpan\" Value=\"2\" />");
|
|
source.ShouldContain("<Setter Property=\"Grid.RowSpan\" Value=\"2\" />");
|
|
source.ShouldNotContain("Selector=\"^[AllowAutoHide=True] /template/ atom|ScopeAwareOverlayLayerPanel#PART_ContentHost\"");
|
|
source.ShouldNotContain("Selector=\"^[IsLiteMode=True] /template/ atom|ScopeAwareOverlayLayerPanel#PART_ContentHost\"");
|
|
source.ShouldNotContain("ScopeAwareOverlayLayerGrid");
|
|
source.ShouldNotContain("Selector=\"^[AllowAutoHide=True] /template/ ScrollContentPresenter#PART_ContentPresenter\"");
|
|
source.ShouldNotContain("Selector=\"^[IsLiteMode=True] /template/ ScrollContentPresenter#PART_ContentPresenter\"");
|
|
}
|
|
|
|
[Fact]
|
|
public void Avalonia_AutoHide_Mode_Keeps_Scroll_Content_Behind_ScrollBars()
|
|
{
|
|
var source = ReadRepoFile("src/AtomUI.Desktop.Controls/ScrollViewer/Themes/AvaScrollViewerTheme.axaml");
|
|
|
|
source.ShouldContain("<atom:ScopeAwareOverlayLayerPanel Name=\"PART_ContentHost\"");
|
|
source.ShouldContain("<Grid Name=\"PART_ScrollLayout\"");
|
|
source.ShouldContain("Name=\"PART_ContentHost\"");
|
|
source.ShouldContain("Name=\"PART_ScrollContentHost\"");
|
|
source.ShouldContain("Selector=\"^[AllowAutoHide=True] /template/ Panel#PART_ScrollContentHost\"");
|
|
source.ShouldContain("<Setter Property=\"Grid.ColumnSpan\" Value=\"2\" />");
|
|
source.ShouldContain("<Setter Property=\"Grid.RowSpan\" Value=\"2\" />");
|
|
source.ShouldNotContain("Selector=\"^[AllowAutoHide=True] /template/ atom|ScopeAwareOverlayLayerPanel#PART_ContentHost\"");
|
|
source.ShouldNotContain("ScopeAwareOverlayLayerGrid");
|
|
source.ShouldNotContain("Selector=\"^[AllowAutoHide=True] /template/ ScrollContentPresenter#ContentPresenter\"");
|
|
source.ShouldNotContain("Selector=\"^[AllowAutoHide=True] /template/ ScrollContentPresenter#PART_ContentPresenter\"");
|
|
}
|
|
|
|
private static string ReadRepoFile(string relativePath)
|
|
{
|
|
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (directory is not null)
|
|
{
|
|
var candidate = Path.Combine(directory.FullName, relativePath);
|
|
if (File.Exists(candidate))
|
|
{
|
|
return File.ReadAllText(candidate);
|
|
}
|
|
|
|
directory = directory.Parent;
|
|
}
|
|
|
|
throw new FileNotFoundException($"Could not find repository file: {relativePath}");
|
|
}
|
|
}
|