2017-05-04 12:51:01 +03:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using Xamarin.Forms.CustomAttributes;
|
|
|
|
using Xamarin.Forms.Internals;
|
|
|
|
#if UITEST
|
|
|
|
using NUnit.Framework;
|
2017-09-15 21:49:19 +03:00
|
|
|
using Xamarin.Forms.Core.UITests;
|
2017-05-04 12:51:01 +03:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Xamarin.Forms.Controls.Issues
|
|
|
|
{
|
2017-09-15 21:49:19 +03:00
|
|
|
#if UITEST
|
|
|
|
[Category(UITestCategories.Gestures)]
|
|
|
|
#endif
|
|
|
|
|
2017-05-04 12:51:01 +03:00
|
|
|
[Preserve(AllMembers = true)]
|
2017-06-20 18:40:07 +03:00
|
|
|
[Issue(IssueTracker.Bugzilla, 55912, "Tap event not always propagated to containing Grid/StackLayout",
|
2017-05-04 12:51:01 +03:00
|
|
|
PlatformAffected.Android)]
|
|
|
|
public class Bugzilla55912 : TestContentPage
|
|
|
|
{
|
|
|
|
const string Success = "Success";
|
|
|
|
const string GridLabelId = "GridLabel";
|
|
|
|
const string StackLabelId = "StackLabel";
|
|
|
|
|
|
|
|
protected override void Init()
|
|
|
|
{
|
|
|
|
var layout = new Grid();
|
|
|
|
|
|
|
|
layout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });
|
|
|
|
layout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });
|
|
|
|
layout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });
|
|
|
|
|
2017-06-20 18:40:07 +03:00
|
|
|
var testGrid = new Grid { BackgroundColor = Color.Red, AutomationId = "testgrid"};
|
2017-05-04 12:51:01 +03:00
|
|
|
var gridLabel = new Label
|
|
|
|
{
|
|
|
|
AutomationId = GridLabelId,
|
|
|
|
Text = "This is a Grid with a TapGesture",
|
|
|
|
FontSize = 24,
|
|
|
|
BackgroundColor = Color.Green
|
|
|
|
};
|
|
|
|
Grid.SetRow(testGrid, 1);
|
|
|
|
testGrid.Children.Add(gridLabel);
|
|
|
|
|
2017-06-20 18:40:07 +03:00
|
|
|
var testStack = new StackLayout { BackgroundColor = Color.Default, AutomationId = "teststack"};
|
2017-05-04 12:51:01 +03:00
|
|
|
var stackLabel = new Label
|
|
|
|
{
|
|
|
|
AutomationId = StackLabelId,
|
|
|
|
Text = "This StackLayout also has a TapGesture",
|
|
|
|
FontSize = 24,
|
|
|
|
BackgroundColor = Color.Green
|
|
|
|
};
|
|
|
|
Grid.SetRow(testStack, 2);
|
|
|
|
testStack.Children.Add(stackLabel);
|
|
|
|
|
|
|
|
layout.Children.Add(testGrid);
|
|
|
|
layout.Children.Add(testStack);
|
|
|
|
|
|
|
|
Content = layout;
|
|
|
|
|
|
|
|
testGrid.GestureRecognizers.Add(new TapGestureRecognizer
|
|
|
|
{
|
|
|
|
NumberOfTapsRequired = 1,
|
|
|
|
Command = new Command(() =>
|
|
|
|
{
|
|
|
|
Debug.WriteLine($"***** TestGrid Tapped: {DateTime.Now} *****");
|
|
|
|
layout.Children.Add(new Label { AutomationId = Success, Text = Success });
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
testStack.GestureRecognizers.Add(new TapGestureRecognizer
|
|
|
|
{
|
|
|
|
NumberOfTapsRequired = 1,
|
|
|
|
Command = new Command(() =>
|
|
|
|
{
|
|
|
|
Debug.WriteLine($"***** TestStack Tapped: {DateTime.Now} *****");
|
|
|
|
layout.Children.Add(new Label { AutomationId = Success, Text = Success });
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#if UITEST
|
|
|
|
[Test]
|
|
|
|
public void GestureBubblingInStackLayout()
|
|
|
|
{
|
|
|
|
RunningApp.WaitForElement(StackLabelId);
|
|
|
|
RunningApp.Tap(StackLabelId);
|
|
|
|
RunningApp.WaitForElement(Success);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void GestureBubblingInGrid()
|
|
|
|
{
|
|
|
|
RunningApp.WaitForElement(GridLabelId);
|
|
|
|
RunningApp.Tap(GridLabelId);
|
|
|
|
RunningApp.WaitForElement(Success);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|