|
|
|
@ -913,111 +913,53 @@ public class TabbedPageTests |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class IconTests : ScopedTestBase |
|
|
|
public class PageIconTemplateTests : ScopedTestBase |
|
|
|
{ |
|
|
|
[Fact] |
|
|
|
public void Geometry_ReturnsPath() |
|
|
|
public void Page_Icon_AcceptsControlValue() |
|
|
|
{ |
|
|
|
var geometry = new EllipseGeometry { Rect = new Rect(0, 0, 10, 10) }; |
|
|
|
var result = TabbedPage.CreateIconContent(geometry); |
|
|
|
Assert.IsType<Path>(result); |
|
|
|
Assert.Same(geometry, ((Path)result!).Data); |
|
|
|
var icon = new PathIcon { Data = new EllipseGeometry { Rect = new Rect(0, 0, 10, 10) } }; |
|
|
|
var page = new ContentPage { Icon = icon }; |
|
|
|
Assert.Same(icon, page.Icon); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void PathIcon_ReturnsPath() |
|
|
|
public void Page_Icon_AcceptsNonControlValue() |
|
|
|
{ |
|
|
|
var geometry = new EllipseGeometry { Rect = new Rect(0, 0, 10, 10) }; |
|
|
|
var pathIcon = new PathIcon { Data = geometry }; |
|
|
|
var result = TabbedPage.CreateIconContent(pathIcon); |
|
|
|
Assert.IsType<Path>(result); |
|
|
|
Assert.Same(geometry, ((Path)result!).Data); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void EmptyString_ReturnsNull() |
|
|
|
{ |
|
|
|
var result = TabbedPage.CreateIconContent(""); |
|
|
|
Assert.Null(result); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NullString_ReturnsNull() |
|
|
|
{ |
|
|
|
var result = TabbedPage.CreateIconContent((string?)null); |
|
|
|
Assert.Null(result); |
|
|
|
var page = new ContentPage { Icon = geometry }; |
|
|
|
Assert.Same(geometry, page.Icon); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Null_ReturnsNull() |
|
|
|
public void Page_IconTemplate_RoundTrips() |
|
|
|
{ |
|
|
|
var result = TabbedPage.CreateIconContent(null); |
|
|
|
Assert.Null(result); |
|
|
|
var template = new FuncDataTemplate<object>((_, _) => new Border()); |
|
|
|
var page = new ContentPage { IconTemplate = template }; |
|
|
|
Assert.Same(template, page.IconTemplate); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void DrawingImage_WithGeometryDrawing_ReturnsPath() |
|
|
|
public void DrawerPage_DrawerIconTemplate_RoundTrips() |
|
|
|
{ |
|
|
|
var geometry = new EllipseGeometry { Rect = new Rect(0, 0, 10, 10) }; |
|
|
|
var drawing = new GeometryDrawing { Geometry = geometry }; |
|
|
|
var drawingImage = new DrawingImage(drawing); |
|
|
|
var result = TabbedPage.CreateIconContent(drawingImage); |
|
|
|
Assert.IsType<Path>(result); |
|
|
|
Assert.Same(geometry, ((Path)result!).Data); |
|
|
|
var template = new FuncDataTemplate<object>((_, _) => new Border()); |
|
|
|
var dp = new DrawerPage { DrawerIconTemplate = template }; |
|
|
|
Assert.Same(template, dp.DrawerIconTemplate); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Path_HasStretchUniform() |
|
|
|
public void DrawerPage_DrawerIcon_With_Geometry_Does_Not_Throw() |
|
|
|
{ |
|
|
|
var geometry = new EllipseGeometry { Rect = new Rect(0, 0, 10, 10) }; |
|
|
|
var result = TabbedPage.CreateIconContent(geometry); |
|
|
|
Assert.Equal(Stretch.Uniform, ((Path)result!).Stretch); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Image_ReturnsImage() |
|
|
|
{ |
|
|
|
var image = new TestImage(); |
|
|
|
var result = TabbedPage.CreateIconContent(image); |
|
|
|
Assert.IsType<Image>(result); |
|
|
|
Assert.Same(image, ((Image)result!).Source); |
|
|
|
} |
|
|
|
|
|
|
|
private sealed class TestImage : IImage |
|
|
|
{ |
|
|
|
public Size Size => new Size(1, 1); |
|
|
|
public void Draw(DrawingContext context, Rect sourceRect, Rect destRect) { } |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Template_BuildsControl() |
|
|
|
{ |
|
|
|
var template = new FuncTemplate<Control>(() => new Border()); |
|
|
|
var result = TabbedPage.CreateIconContent(template); |
|
|
|
Assert.IsType<Border>(result); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Template_BuildsSeparateInstances() |
|
|
|
{ |
|
|
|
var template = new FuncTemplate<Control>(() => new Border()); |
|
|
|
var first = TabbedPage.CreateIconContent(template); |
|
|
|
var second = TabbedPage.CreateIconContent(template); |
|
|
|
Assert.NotSame(first, second); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NonEmptyString_ReturnsNull() |
|
|
|
{ |
|
|
|
var result = TabbedPage.CreateIconContent("M10 20v-6h4v6"); |
|
|
|
Assert.Null(result); |
|
|
|
} |
|
|
|
var dp = new DrawerPage |
|
|
|
{ |
|
|
|
DrawerIcon = geometry, |
|
|
|
DrawerIconTemplate = new FuncDataTemplate<object>((_, _) => new PathIcon()), |
|
|
|
}; |
|
|
|
var root = new TestRoot { Child = dp }; |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void UnsupportedType_ReturnsNull() |
|
|
|
{ |
|
|
|
var result = TabbedPage.CreateIconContent(42); |
|
|
|
Assert.Null(result); |
|
|
|
dp.DrawerIcon = new EllipseGeometry { Rect = new Rect(0, 0, 20, 20) }; |
|
|
|
Assert.NotNull(dp.DrawerIcon); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|