-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue1414.cs
91 lines (81 loc) · 2.49 KB
/
Issue1414.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
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.UwpIgnore)]
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1414, "InvalidCastException when scrolling and refreshing TableView", PlatformAffected.iOS)]
public class Issue1414 : TestContentPage
{
ViewCell BuildCell(int sectionIndex, int cellIndex)
{
var grid = new Grid
{
ColumnDefinitions = {
new ColumnDefinition { Width = GridLength.Star },
new ColumnDefinition { Width = GridLength.Star }
},
AutomationId = $"Row-{sectionIndex}-{cellIndex}"
};
if (cellIndex % 2 == 0)
{
grid.AddChild(new Label { Text = $"Cell {sectionIndex}-{cellIndex}" }, 0, 0);
grid.AddChild(new Label { Text = $"Label" }, 1, 0);
grid.BackgroundColor = Color.Fuchsia;
}
else
{
grid.AddChild(new Label { Text = $"Cell {sectionIndex}-{cellIndex}" }, 0, 0);
grid.AddChild(new Entry { Text = $"Entry" }, 1, 0);
grid.BackgroundColor = Color.Yellow;
}
return new ViewCell
{
View = grid,
};
}
protected override void Init()
{
var tableView = new Xamarin.Forms.TableView
{
HasUnevenRows = true,
Intent = TableIntent.Form,
Root = new TableRoot(),
AutomationId = "TableView"
};
for (int sectionIndex = 0; sectionIndex < 5; sectionIndex++)
{
var section = new TableSection($"Section {sectionIndex}");
for (int cellIndex = 0; cellIndex < 25; cellIndex++)
{
section.Add(BuildCell(sectionIndex, cellIndex));
}
tableView.Root.Add(section);
}
Content = tableView;
}
#if UITEST
[Test]
public void InvalidCastExceptionWhenScrollingAndRefreshingTableView()
{
RunningApp.Screenshot("Start G1414");
var tableFrame = RunningApp.WaitForElement(q => q.Marked("TableView"))[0].Rect;
RunningApp.ScrollForElement("* marked:'Row-4-24'", new Drag(tableFrame, Drag.Direction.BottomToTop, Drag.DragLength.Long));
RunningApp.Screenshot("Scrolled to end without crashing!");
RunningApp.ScrollForElement("* marked:'Row-0-0'", new Drag(tableFrame, Drag.Direction.TopToBottom, Drag.DragLength.Long));
RunningApp.Screenshot("Scrolled to top without crashing!");
}
#endif
}
}