/
WindowTests.cs
86 lines (74 loc) · 2.25 KB
/
WindowTests.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
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 Microsoft.Maui.Hosting;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.DeviceTests.Stubs;
#if ANDROID || IOS
using ShellHandler = Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer;
#endif
namespace Microsoft.Maui.DeviceTests
{
[Category(TestCategory.Window)]
#if ANDROID
[Collection(HandlerTestBase.RunInNewWindowCollection)]
#endif
public partial class WindowTests : HandlerTestBase
{
void SetupBuilder()
{
EnsureHandlerCreated(builder =>
{
builder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(Controls.Shell), typeof(ShellHandler));
handlers.AddHandler<Layout, LayoutHandler>();
handlers.AddHandler<Image, ImageHandler>();
handlers.AddHandler<Label, LabelHandler>();
handlers.AddHandler<Page, PageHandler>();
handlers.AddHandler<Toolbar, ToolbarHandler>();
handlers.AddHandler(typeof(NavigationPage), typeof(NavigationViewHandler));
#if WINDOWS
handlers.AddHandler<ShellItem, ShellItemHandler>();
handlers.AddHandler<ShellSection, ShellSectionHandler>();
handlers.AddHandler<ShellContent, ShellContentHandler>();
#endif
});
});
}
#if !IOS
// Automated Shell tests are currently broken via xharness
[Fact(DisplayName = "Toolbar Items Update when swapping out Main Page on Handler")]
public async Task ToolbarItemsUpdateWhenSwappingOutMainPageOnHandler()
{
SetupBuilder();
var toolbarItem = new ToolbarItem() { Text = "Toolbar Item 1" };
var firstPage = new ContentPage();
var window = new Window(firstPage);
await CreateHandlerAndAddToWindow<WindowHandlerStub>(window, async (handler) =>
{
var contentPage = new ContentPage()
{
ToolbarItems =
{
toolbarItem
}
};
var shell = new Shell() { CurrentItem = contentPage };
window.Page = shell;
await OnLoadedAsync(shell);
await OnLoadedAsync(shell.CurrentPage);
ToolbarItemsMatch(handler, toolbarItem);
});
}
#endif
}
}