blob: 6c645eeb84f7fc8c10e9e460abc729c32ac10fa6 (
plain)
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
|
using System;
using Xamarin.Forms.CustomAttributes;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls
{
[Preserve (AllMembers = true)]
[Issue (IssueTracker.Github, 2954, "Cell becomes empty after adding a new one with context actions (TableView) ")]
public class Issue2954 : TestContentPage // or TestMasterDetailPage, etc ...
{
TableSection _dataSection;
TableView _tableView;
int _count = 0;
protected override void Init ()
{
_dataSection = new TableSection {
new TextCell{ Text = "Cell1" },
new TextCell{ Text = "Cell2", ContextActions = { new MenuItem{ Text = "Delete" } } },
new TextCell{ Text = "Add new", Command = new Command (AddNew) }
};
_tableView = new TableView {
Root = new TableRoot {
_dataSection
}
};
Content = _tableView;
}
void AddNew (object parameters)
{
_count++;
_dataSection.Insert (0, new TextCell { Text = "Fresh cell " + _count
, ContextActions = { new MenuItem{ Text = "Delete" } }
});
_tableView.Root = _tableView.Root; //HACK - force table reload
}
#if UITEST
[Test]
public void Issue2954Test ()
{
RunningApp.Screenshot ("I am at Issue 2954");
RunningApp.WaitForElement (q => q.Marked ("Cell2"));
RunningApp.Screenshot ("I see the Cell2");
RunningApp.Tap(c => c.Marked("Add new"));
RunningApp.WaitForElement (q => q.Marked ("Cell2"));
RunningApp.Screenshot ("I still see the Cell2");
}
#endif
}
}
|