/
FlyoutPageTests.cs
106 lines (94 loc) · 3.01 KB
/
FlyoutPageTests.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
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers;
using Microsoft.Maui.DeviceTests.Stubs;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Platform;
using Xunit;
namespace Microsoft.Maui.DeviceTests
{
[Category(TestCategory.FlyoutPage)]
public partial class FlyoutPageTests : HandlerTestBase
{
void SetupBuilder()
{
EnsureHandlerCreated(builder =>
{
builder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(Controls.Toolbar), typeof(ToolbarHandler));
handlers.AddHandler(typeof(FlyoutPage), typeof(FlyoutViewHandler));
handlers.AddHandler(typeof(Controls.NavigationPage), typeof(NavigationViewHandler));
handlers.AddHandler<Page, PageHandler>();
handlers.AddHandler<Controls.Window, WindowHandlerStub>();
});
});
}
#if !IOS
[Fact(DisplayName = "FlyoutPage With Toolbar")]
public async Task FlyoutPageWithToolbar()
{
SetupBuilder();
var flyoutPage = new FlyoutPage()
{
Detail = new NavigationPage(new ContentPage() { Title = "Detail" }),
Flyout = new ContentPage() { Title = "Flyout" }
};
await CreateHandlerAndAddToWindow<FlyoutViewHandler>(flyoutPage, (handler) =>
{
// validate that nothing crashes
return Task.CompletedTask;
});
}
[Fact(DisplayName = "Details View Updates w/NavigationPage")]
public async Task DetailsViewUpdatesWithNavigationPage()
{
SetupBuilder();
var flyoutPage = new FlyoutPage()
{
Detail = new NavigationPage(new ContentPage() { Title = "Detail" }),
Flyout = new ContentPage() { Title = "Flyout" }
};
await CreateHandlerAndAddToWindow<FlyoutViewHandler>(flyoutPage, async (handler) =>
{
var details2 = new NavigationPage(new ContentPage() { Title = "Detail" });
flyoutPage.Detail = details2;
await OnLoadedAsync(details2.CurrentPage);
var detailView2 = (details2.CurrentPage.Handler as IPlatformViewHandler)?.PlatformView;
Assert.NotNull(detailView2);
});
}
[Fact(DisplayName = "Details View Updates")]
public async Task DetailsViewUpdates()
{
SetupBuilder();
var flyoutPage = new FlyoutPage()
{
Detail = new ContentPage() { Title = "Detail" },
Flyout = new ContentPage() { Title = "Flyout" }
};
await CreateHandlerAndAddToWindow<FlyoutViewHandler>(flyoutPage, async (handler) =>
{
var details2 = new ContentPage() { Title = "Detail" };
var flyoutView = flyoutPage.ToPlatform();
var detailView = flyoutPage.Detail.ToPlatform();
var dl = FindPlatformFlyoutView(detailView);
Assert.Equal(flyoutView, dl);
flyoutPage.Detail = details2;
await OnLoadedAsync(details2);
await detailView.OnUnloadedAsync();
dl = FindPlatformFlyoutView(details2.ToPlatform());
Assert.Equal(flyoutView, dl);
Assert.Null(FindPlatformFlyoutView(detailView));
});
}
#endif
}
}