Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Adding instructions and UI tests for Bugzilla44461 #4144

Merged
merged 3 commits into from
Oct 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
using Xamarin.Forms.CustomAttributes;
using System;
using System.Linq;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls
#if UITEST
using Xamarin.UITest;
using Xamarin.UITest.Queries;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 44461, "ScrollToPosition.Center works differently on Android and iOS", PlatformAffected.iOS)]
public class Bugzilla44461 : TestContentPage
{
const string BtnPrefix= "Button";

protected override void Init()
{
var grid = new Grid
{
RowSpacing = 0,
};

var instructions = new Label
{
Text = @"Tap the first button (Button0). The button should be aligned with the left side of the screen "
+ "and should not move. If it's not, the test failed."
};

grid.Children.Add(instructions);

var scrollView = new ScrollView
{
Orientation = ScrollOrientation.Horizontal,
Expand All @@ -33,7 +51,7 @@ protected override void Init()
{
var button = new Button
{
Text = "Button" + i
Text = $"{BtnPrefix}{i}"
};
button.Clicked += (sender, args) =>
{
Expand All @@ -45,5 +63,26 @@ protected override void Init()
scrollView.Content = stackLayout;
Content = grid;
}

#if UITEST && __IOS__
[Test]
public void Bugzilla44461Test()
{
var positions = TapButton(0);
Assert.AreEqual(positions.initialPosition.X, positions.finalPosition.X);
Assert.LessOrEqual(positions.finalPosition.X, 1);
RunningApp.Screenshot ("Button0 is aligned with the left side of the screen");
}

(AppRect initialPosition, AppRect finalPosition ) TapButton(int position)
{
var buttonText = $"{BtnPrefix}{position}";
RunningApp.WaitForElement(q => q.Button(buttonText));
var initialPosition = RunningApp.Query(buttonText)[0].Rect;
RunningApp.Tap(q => q.Button(buttonText));
var finalPosition = RunningApp.Query(buttonText)[0].Rect;
return (initialPosition, finalPosition);
}
#endif
}
}
}