summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue342.cs
blob: 2a66a84ab80437bff2a8399e73b2fc47d1ca6c57 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Linq;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 342, "NRE when Image is not assigned source", PlatformAffected.WinPhone)]
	public class Issue342NoSource : TestContentPage
	{
		protected override void Init ()
		{
			Title = "Issue 342";
			Content = new StackLayout {
				Children = {
					new Label {
						Text = "Uninitialized image"
					},
					new Image ()
				}
			};
		}

		// Should not throw exception when user does not include image

#if UITEST
		[Test]
		public void Issue342NoSourceTestsLablePresentNoImage ()
		{
			RunningApp.WaitForElement (q => q.Marked ("Uninitialized image"), "Cannot see label");
			RunningApp.Screenshot ("All elements present");
		}
#endif
    }

	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 342, "NRE when Image is delayed source", PlatformAffected.WinPhone)]
	public class Issue342DelayedSource : TestContentPage
	{
		protected override void Init ()
		{
			Title = "Issue 342";

			_image = new Image ();

			Content = new StackLayout {
				Children = { 
					new Label {
						Text = "Delayed image"
					},
					_image 
				}
			};

			AddSourceAfterDelay ();
		}

		// Should not throw exception when user does not include image
		Image _image;

		void AddSourceAfterDelay ()
		{
			Device.StartTimer (TimeSpan.FromSeconds (2), () => {
				_image.Source = "cover1.jpg";
				return false;
			});
		}

#if UITEST
		[Test]
		[Category(UITestCategories.ManualReview)]
		public void Issue342DelayedLoadTestsImageLoads ()
		{
			RunningApp.Screenshot ("Should not crash");
		}
#endif
	}
}