/
ListViewTests.cs
64 lines (60 loc) · 1.45 KB
/
ListViewTests.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
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Hosting;
using Xunit;
namespace Microsoft.Maui.DeviceTests
{
[Collection(HandlerTestBase.RunInNewWindowCollection)]
[Category(TestCategory.ListView)]
public partial class ListViewTests : HandlerTestBase
{
void SetupBuilder()
{
EnsureHandlerCreated(builder =>
{
builder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler<ViewCell, ViewCellRenderer>();
handlers.AddHandler<ListView, ListViewRenderer>();
handlers.AddHandler<VerticalStackLayout, LayoutHandler>();
handlers.AddHandler<Label, LabelHandler>();
});
});
}
[Fact(DisplayName = "ReAssigning ListView in VSL Crashes")]
public async Task ReAssigninListViewInVSLCrashes()
{
SetupBuilder();
var listView = new ListView()
{
ItemTemplate = new DataTemplate(() =>
{
return new ViewCell()
{
View = new VerticalStackLayout()
{
new Label()
{
Text = "Cat"
}
}
};
})
};
var layout = new VerticalStackLayout()
{
listView
};
await CreateHandlerAndAddToWindow<LayoutHandler>(layout, async (handler) =>
{
listView.ItemsSource = Enumerable.Range(1, 1);
await Task.Delay(100);
listView.ItemsSource = Enumerable.Range(1, 2);
await Task.Delay(100);
});
}
}
}