test: add unit tests for controls and rendering helpers
All checks were successful
CI / Build (Linux) (push) Successful in 18s
All checks were successful
CI / Build (Linux) (push) Successful in 18s
Add comprehensive test coverage for 20+ Skia controls including ActivityIndicator, Border, CheckBox, CollectionView, DatePicker, Editor, Grid, Image, ImageButton, Label, NavigationPage, Page, Picker, ProgressBar, RadioButton, SearchBar, Stepper, Switch, and TimePicker. Include tests for TextRenderingHelper utility methods covering color conversion, font style mapping, and font family resolution.
This commit is contained in:
68
tests/Views/SkiaPageTests.cs
Normal file
68
tests/Views/SkiaPageTests.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using FluentAssertions;
|
||||
using Microsoft.Maui.Graphics;
|
||||
using Microsoft.Maui.Platform;
|
||||
using SkiaSharp;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Maui.Controls.Linux.Tests.Views;
|
||||
|
||||
public class SkiaPageTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_SetsDefaultValues()
|
||||
{
|
||||
// Arrange & Act
|
||||
var page = new SkiaPage();
|
||||
|
||||
// Assert
|
||||
page.Title.Should().BeEmpty();
|
||||
page.IsVisible.Should().BeTrue();
|
||||
page.IsEnabled.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Title_WhenSet_UpdatesProperty()
|
||||
{
|
||||
// Arrange
|
||||
var page = new SkiaPage();
|
||||
|
||||
// Act
|
||||
page.Title = "My Page";
|
||||
|
||||
// Assert
|
||||
page.Title.Should().Be("My Page");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BackgroundColor_WhenSet_UpdatesProperty()
|
||||
{
|
||||
// Arrange
|
||||
var page = new SkiaPage();
|
||||
var color = Microsoft.Maui.Graphics.Colors.LightGray;
|
||||
|
||||
// Act
|
||||
page.BackgroundColor = color;
|
||||
|
||||
// Assert
|
||||
page.BackgroundColor.Should().Be(color);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Draw_DoesNotThrow()
|
||||
{
|
||||
// Arrange
|
||||
var page = new SkiaPage();
|
||||
page.Title = "Test Page";
|
||||
page.Bounds = new Rect(0, 0, 400, 600);
|
||||
|
||||
using var surface = SKSurface.Create(new SKImageInfo(400, 600));
|
||||
var canvas = surface.Canvas;
|
||||
|
||||
// Act & Assert
|
||||
var exception = Record.Exception(() => page.Draw(canvas));
|
||||
exception.Should().BeNull();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user