summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2241.cs
blob: 971b537f8b8a76500eea1aa4baf2065e8cfda55e (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
using System;

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

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

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Github, 2241, "ScrollView content can become stuck on orientation change (iOS)", PlatformAffected.iOS)]
	public class Issue2241 : TestContentPage
	{
		protected override void Init ()
		{
			ScrollView scrollView = new ScrollView () {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Padding = new Thickness (20),
				Content = new BoxView () {
					Color = Color.Red,
					HeightRequest = 400,
					HorizontalOptions = LayoutOptions.FillAndExpand
				}
			};

			Content = scrollView;
		}

#if UITEST
		[Test]
		[Ignore("Fails intermittently on TestCloud")]
		public void ChangeOrientationCheckScroll ()
		{
#if __ANDROID__
			var isAndroid = true;
#else
			var isAndroid = false;
#endif
			var className = "Xamarin_Forms_Platform_iOS_BoxRenderer";
			if (isAndroid) {
				className = "BoxRenderer";
			}
			var box1 = RunningApp.Query (c => c.Class (className)) [0];
			RunningApp.SetOrientationLandscape ();
			RunningApp.ScrollDown ();
			RunningApp.SetOrientationPortrait ();
			var box2 = RunningApp.Query (c => c.Class (className)) [0];
			RunningApp.Screenshot ("Did it resize ok? Do you see some white on the bottom?");
			if (!isAndroid) {
				Assert.AreEqual (box1.Rect.CenterY, box2.Rect.CenterY);
			}
		}
#endif
	}
}