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

using Xamarin.Forms.CustomAttributes;
using System.Threading.Tasks;
using Xamarin.Forms.Internals;

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

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 35733, "iOS WebView crashes when loading an URL with encoded parameters", PlatformAffected.iOS)]
	public class Bugzilla35733 : TestContentPage // or TestMasterDetailPage, etc ...
	{
		protected override void Init ()
		{
			var thisDoesNotWorkButton = new Button {
				Text = "This will crash",
				AutomationId = "btnGo"

			};
			thisDoesNotWorkButton.Clicked += async (object sender, EventArgs e) => await ShowLocation ("KÅRA");

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Center,
				Children = {
					thisDoesNotWorkButton
				}
			};
		}

		async Task ShowLocation(string locationString) 
		{
			var stringUri = string.Format("http://m.liu.se/karta/karta?l=en&px_location={0}", Uri.EscapeDataString(locationString));
			var uri = new Uri(stringUri);
			var webPage = new ContentPage {
				Title = "WebViewTest",
				Content = new WebView {
					Source = uri
				}
			};
			await Navigation.PushAsync(webPage);
		}

#if UITEST
		[Test]
		public void Bugzilla35733Test ()
		{
			RunningApp.WaitForElement (q => q.Marked ("btnGo"));
			RunningApp.Tap (q => q.Marked ("btnGo"));
			RunningApp.WaitForElement (q => q.Marked ("WebViewTest"));
			RunningApp.Screenshot ("I didn't crash");
		}
#endif
	}
}