/
FlyoutPageTests.Windows.cs
94 lines (85 loc) · 2.93 KB
/
FlyoutPageTests.Windows.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers;
using Microsoft.Maui.Platform;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using WPanel = Microsoft.UI.Xaml.Controls.Panel;
using WFrameworkElement = Microsoft.UI.Xaml.FrameworkElement;
using WWindow = Microsoft.UI.Xaml.Window;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Handlers;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Maui.DeviceTests.Stubs;
namespace Microsoft.Maui.DeviceTests
{
[Category(TestCategory.FlyoutPage)]
public partial class FlyoutPageTests : HandlerTestBase
{
[Fact(DisplayName = "FlyoutPage Initializes with FlyoutCustomContent Set")]
public async Task FlyoutPageInitializesWithFlyoutCustomContentSet()
{
SetupBuilder();
var flyoutPage = CreateBasicFlyoutPage();
await CreateHandlerAndAddToWindow<FlyoutViewHandler>(flyoutPage, (handler) =>
{
Assert.NotNull(handler.PlatformView.FlyoutCustomContent);
Assert.NotNull(handler.PlatformView.PaneCustomContent);
return Task.CompletedTask;
});
}
[Fact(DisplayName = "FlyoutPage Initializes with Header Set")]
public async Task FlyoutPageInitializesWithHeaderSet()
{
SetupBuilder();
var flyoutPage = CreateBasicFlyoutPage();
await CreateHandlerAndAddToWindow<WindowHandlerStub>(new Window(flyoutPage), (handler) =>
{
var navView = GetMauiNavigationView(handler.MauiContext);
Assert.NotNull(navView.Header);
return Task.CompletedTask;
});
}
[Fact(DisplayName = "Flyout Locked Offset")]
public async Task FlyoutLockedOffset()
{
SetupBuilder();
var flyout = CreateBasicFlyoutPage();
await CreateHandlerAndAddToWindow<FlyoutViewHandler>(flyout, (handler) =>
{
flyout.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Split;
var distance = DistanceYFromTheBottomOfTheAppTitleBar(flyout.Flyout);
Assert.True(Math.Abs(distance) < 1);
return Task.CompletedTask;
});
}
[Fact(DisplayName = "Flyout Locked Offset from App Title Bar With Pushed Page")]
public async Task FlyoutLockedOffsetFromAppTitleBarWithPushedPage()
{
SetupBuilder();
var flyout = CreateBasicFlyoutPage();
await CreateHandlerAndAddToWindow<FlyoutViewHandler>(flyout, async (handler) =>
{
flyout.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Split;
await flyout.Detail.Navigation.PushAsync(new ContentPage());
var distance = DistanceYFromTheBottomOfTheAppTitleBar(flyout.Flyout);
Assert.True(Math.Abs(distance) < 1);
});
}
NavigationView FindPlatformFlyoutView(WFrameworkElement aView) =>
aView.GetParentOfType<NavigationView>();
FlyoutPage CreateBasicFlyoutPage()
{
return new FlyoutPage()
{
Detail = new NavigationPage(new ContentPage() { Title = "Detail" }) { Title = "NavigationPage Detail" },
Flyout = new ContentPage() { Title = "Flyout" }
};
}
}
}