-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Bugzilla57674.cs
97 lines (83 loc) · 2.27 KB
/
Bugzilla57674.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
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Collections.Generic;
using System.Collections.Specialized;
using System;
using System.Collections;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Bugzilla)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 57674, "ListView not honoring INotifyCollectionChanged ", PlatformAffected.UWP)]
public class Bugzilla57674 : TestContentPage
{
MyCollection _myCollection;
protected override void Init()
{
// Initialize ui here instead of ctor
_myCollection = new MyCollection();
var stackLayout = new StackLayout();
var button = new Button {
AutomationId = "IssueButton",
Text = "Add new element to ListView"
};
button.Clicked += (object sender, EventArgs e) => _myCollection.AddNewItem();
stackLayout.Children.Add(button);
stackLayout.Children.Add(new ListView {
AutomationId = "IssueListView",
ItemsSource = _myCollection
});
Content = stackLayout;
}
#if UITEST
[Test]
public void Bugzilla57674Test()
{
RunningApp.Screenshot("Initial Status");
RunningApp.WaitForElement(q => q.Marked("IssueListView"));
RunningApp.Tap(a => a.Button("IssueButton"));
RunningApp.Screenshot("Element Added to List");
}
#endif
}
public class MyCollection : IEnumerable<string>, INotifyCollectionChanged
{
readonly List<string> _internalList = new List<string>();
public MyCollection()
{
}
public IEnumerable<string> GetItems()
{
foreach (var item in _internalList)
{
yield return item;
}
}
public IEnumerator<string> GetEnumerator()
{
return GetItems().GetEnumerator();
}
public void AddNewItem()
{
int index = _internalList.Count;
string item = Guid.NewGuid().ToString();
_internalList.Add(item);
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
}
public event NotifyCollectionChangedEventHandler CollectionChanged;
protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
CollectionChanged?.Invoke(this, e);
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}