summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue530.cs
blob: 34d8f22c1c896e2abf7823a59518fb4609b7d191 (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
59
60
61
62
63
64
65
66
67
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using NUnit.Framework;
using Xamarin.UITest;
#endif

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Github, 530, "ListView does not render if source is async", PlatformAffected.iOS)]
	public class Issue530 : TestContentPage
	{
		ListView _list;
		Button _button;

		protected override void Init ()
		{
			var dataTemplate = new DataTemplate (typeof (TextCell));
			dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("."));

			_list = new ListView { 
				ItemTemplate = dataTemplate
			};

			_button = new Button {
				Text = "Load",
			};

			_button.Clicked += async (sender, e) => {
				await Task.Delay (1000);
				_list.ItemsSource = new [] {"John","Paul", "George", "Ringo"};
			};
			Content = new StackLayout {
				Children = {
					_button,
					_list,
				}
			};
		}

#if UITEST
		[Test]
		[UiTest (typeof(ListView))]
		public void Issue530TestsLoadAsync ()
		{
			RunningApp.WaitForElement (q => q.Button ("Load"));
			RunningApp.Screenshot ("All elements present");
			RunningApp.Tap (q => q.Button ("Load"));

			RunningApp.WaitForElement (q => q.Marked ("John"));
			RunningApp.WaitForElement (q => q.Marked ("Paul"));
			RunningApp.WaitForElement (q => q.Marked ("George"));
			RunningApp.WaitForElement (q => q.Marked ("Ringo"));

			RunningApp.Screenshot ("List items loaded async");
		}
#endif

	}	
}