2016-03-22 23:02:25 +03:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using Xamarin.Forms.CustomAttributes;
|
2016-04-26 18:20:55 +03:00
|
|
|
using Xamarin.Forms.Internals;
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
#if UITEST
|
|
|
|
using Xamarin.Forms.Core.UITests;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using Xamarin.UITest;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-11-17 00:07:30 +03:00
|
|
|
namespace Xamarin.Forms.Controls.Issues
|
2016-03-22 23:02:25 +03:00
|
|
|
{
|
2018-11-21 14:48:05 +03:00
|
|
|
#if UITEST
|
|
|
|
[NUnit.Framework.Category(Core.UITests.UITestCategories.UwpIgnore)]
|
|
|
|
#endif
|
2016-03-22 23:02:25 +03:00
|
|
|
[Preserve (AllMembers = true)]
|
|
|
|
[Issue (IssueTracker.Bugzilla, 35472, "PopAsync during ScrollToAsync throws NullReferenceException")]
|
|
|
|
public class Bugzilla35472 : TestNavigationPage
|
|
|
|
{
|
|
|
|
protected override void Init ()
|
|
|
|
{
|
|
|
|
// Set up the scroll viewer page
|
|
|
|
var scrollToButton = new Button () { Text = "Now push this button" };
|
|
|
|
|
|
|
|
var stackLayout = new StackLayout ();
|
|
|
|
|
|
|
|
stackLayout.Children.Add (scrollToButton);
|
|
|
|
|
|
|
|
for (int n = 0; n < 100; n++) {
|
|
|
|
stackLayout.Children.Add (new Label () { Text = n.ToString () });
|
|
|
|
}
|
|
|
|
|
|
|
|
var scrollView = new ScrollView () {
|
|
|
|
Content = stackLayout
|
|
|
|
};
|
|
|
|
|
|
|
|
var pageWithScrollView = new ContentPage () {
|
|
|
|
Content = scrollView
|
|
|
|
};
|
|
|
|
|
|
|
|
// Set up the start page
|
|
|
|
var goButton = new Button () {
|
|
|
|
Text = "Push this button"
|
|
|
|
};
|
|
|
|
|
|
|
|
var successLabel = new Label () { Text = "The test has passed", IsVisible = false };
|
|
|
|
|
|
|
|
var startPage = new ContentPage () {
|
|
|
|
Content = new StackLayout {
|
|
|
|
VerticalOptions = LayoutOptions.Center,
|
|
|
|
Children = {
|
|
|
|
goButton,
|
|
|
|
successLabel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
PushAsync (startPage);
|
|
|
|
|
|
|
|
goButton.Clicked += (sender, args) => Navigation.PushAsync (pageWithScrollView);
|
|
|
|
|
|
|
|
scrollToButton.Clicked += async (sender, args) => {
|
|
|
|
try {
|
2019-03-27 21:38:38 +03:00
|
|
|
#pragma warning disable 4014
|
|
|
|
// Deliberately not awaited so we can simulate a user navigating back before the scroll is finished
|
2016-03-22 23:02:25 +03:00
|
|
|
scrollView.ScrollToAsync (0, 1500, true);
|
2019-03-27 21:38:38 +03:00
|
|
|
#pragma warning restore 4014
|
2016-03-22 23:02:25 +03:00
|
|
|
await Navigation.PopAsync ();
|
|
|
|
successLabel.IsVisible = true;
|
|
|
|
} catch (Exception ex) {
|
|
|
|
Debug.WriteLine (ex);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#if UITEST
|
|
|
|
[Test]
|
|
|
|
[UiTest (typeof(NavigationPage))]
|
|
|
|
public void Issue35472PopAsyncDuringAnimatedScrollToAsync ()
|
|
|
|
{
|
|
|
|
RunningApp.WaitForElement (q => q.Marked ("Push this button"));
|
|
|
|
RunningApp.Tap (q => q.Marked ("Push this button"));
|
|
|
|
|
|
|
|
RunningApp.WaitForElement (q => q.Marked ("Now push this button"));
|
|
|
|
RunningApp.Screenshot ("On Page With ScrollView");
|
|
|
|
RunningApp.Tap (q => q.Marked ("Now push this button"));
|
|
|
|
|
|
|
|
RunningApp.WaitForElement ("The test has passed");
|
|
|
|
RunningApp.Screenshot ("Success");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|