Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cb28802
Repro
hartez Aug 23, 2017
bef3f63
Fail test if tap command is executed more than once.
hartez Aug 23, 2017
c979074
Update error message
hartez Aug 23, 2017
3b565f7
Handle context actions and taps without breaking selection
hartez Aug 24, 2017
5500a15
Fix 58833 test
samhouts Aug 25, 2017
d96d23c
Prevent InnerGestureListener from swallowing clicks and preventing se…
hartez Aug 29, 2017
55a68f5
Repro for 57515
hartez Sep 6, 2017
82d6acf
Add gestures category to appropriate tests
hartez Sep 7, 2017
422907b
Test notes
hartez Sep 7, 2017
58f9a5c
Restore the tap gesture handling
hartez Sep 7, 2017
0ada9a3
Better test name
hartez Sep 7, 2017
1c965e5
Simplify InnerGestureListener constructor; handle OnDown only if list…
hartez Sep 7, 2017
4970af4
OnInterceptTouchEvent for IsEnabled handling
hartez Sep 7, 2017
35bf910
Fix incorrect class filter in TapGestureHandler
hartez Sep 8, 2017
691a5f9
Restore MotionEventHelper
hartez Sep 8, 2017
2fed7b9
Add IsEnabled check on OnTouchEvent
hartez Sep 8, 2017
3d81f36
Reinstate pinch gestures
hartez Sep 8, 2017
52741a1
Checkpoint (trying to figure out how to handle button elevation)
hartez Sep 9, 2017
7c9fa74
Rip out elevation ordering in DefaultRenderer
hartez Sep 11, 2017
170fadd
Working version of pinch-to-zoom test
hartez Sep 11, 2017
05f3dec
Clean up lazy initializers, remove unnecessary members
hartez Sep 11, 2017
aeef155
One fewer Java.Lang.Object
hartez Sep 11, 2017
05c9ffc
Fix issue number; clean up notes and issue number changes
hartez Sep 11, 2017
d17a463
Remove conditional
hartez Sep 11, 2017
833e188
Restore correct issue number
hartez Sep 11, 2017
9e867d8
Automate all the options for 58833 test
hartez Sep 11, 2017
fd75d65
Remove unnecessary automation ID
hartez Sep 11, 2017
ad752a3
Formatting cleanup; reinstate gesture detector dispose checks
hartez Sep 11, 2017
a942ceb
Updating Xamarin UI test version to avoid iOS crashes; update test to…
hartez Sep 12, 2017
b8593f6
Merge branch 'master' into gesture-reform
hartez Sep 12, 2017
a8a911c
Attempting to get 58833 test running on all iOS versions
hartez Sep 13, 2017
3eb8a14
Merge branch 'master' into gesture-reform
rmarinho Sep 15, 2017
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,30 +1,35 @@
using System;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif

[Preserve (AllMembers = true)]
[Issue (IssueTracker.Bugzilla, 24574, "Tap Double Tap")]
public class Issue24574 : TestContentPage // or TestMasterDetailPage, etc ...
public class Issue24574 : TestContentPage
{
protected override void Init ()
{
var label = new Label {
AutomationId = "TapLabel",
Text = "123"
Text = "123",
FontSize = 50
};

var rec = new TapGestureRecognizer () { NumberOfTapsRequired = 1 };
var rec = new TapGestureRecognizer { NumberOfTapsRequired = 1 };
rec.Tapped += (s, e) => { label.Text = "Single"; };
label.GestureRecognizers.Add (rec);

rec = new TapGestureRecognizer () { NumberOfTapsRequired = 2 };
rec = new TapGestureRecognizer { NumberOfTapsRequired = 2 };
rec.Tapped += (s, e) => { label.Text = "Double"; };
label.GestureRecognizers.Add (rec);

Expand All @@ -33,7 +38,7 @@ protected override void Init ()

#if UITEST
[Test]
public void Issue1Test ()
public void TapThenDoubleTap ()
{
RunningApp.Screenshot ("I am at Issue 24574");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.InputTransparent)]
[Category(UITestCategories.Gestures)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 25943, "[Android] TapGestureRecognizer does not work with a nested StackLayout", PlatformAffected.Android)]
[Issue(IssueTracker.Bugzilla, 25943,
"[Android] TapGestureRecognizer does not work with a nested StackLayout", PlatformAffected.Android)]
public class Bugzilla25943 : TestContentPage
{
Label _result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

#if UITEST
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest.Queries;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif

[Preserve (AllMembers = true)]
[Issue (IssueTracker.Bugzilla, 35477, "Tapped event does not fire when added to Frame in Android AppCompat",
PlatformAffected.Android)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
[Category(UITestCategories.IsEnabled)]
#endif

[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 36703, "TapGestureRecognizer inside initially disable Image will never fire Tapped event", PlatformAffected.All)]
[Issue(IssueTracker.Bugzilla, 36703,
"TapGestureRecognizer inside initially disable Image will never fire Tapped event", PlatformAffected.All)]
public class Bugzilla36703 : TestContentPage
{
const string TestImage = "testimage";
Expand All @@ -22,7 +29,9 @@ protected override void Init()
var image = new Image { Source = "coffee.png", IsEnabled = false, AutomationId = TestImage };
var button = new Button { Text = $"Toggle IsEnabled (now {image.IsEnabled})", AutomationId = Toggle };
var resultLabel = new Label { Text = "Testing..."};
var instructions = new Label { Text = $"Tap the image. The '{Testing}' label should remain unchanged. Tap the 'Toggle IsEnabled' button. Now tap the image again. The {Testing} Label should change its text to {Success}." };
var instructions = new Label { Text = $"Tap the image. The '{Testing}' label should remain unchanged. "
+ $"Tap the 'Toggle IsEnabled' button. Now tap the image again."
+ $" The {Testing} Label should change its text to {Success}." };

button.Clicked += (sender, args) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif

[Preserve (AllMembers = true)]
[Issue (IssueTracker.Bugzilla, 39530, "Frames do not handle pan or pinch gestures under AppCompat", PlatformAffected.Android)]
public class Bugzilla39530 : TestContentPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif

[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 39768, "PanGestureRecognizer sometimes won't fire completed event when dragging very slowly")]
public class Bugzilla39768 : TestContentPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif

[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 44044, "TabbedPage steals swipe gestures", PlatformAffected.Android)]
public class Bugzilla44044 : TestTabbedPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
[Category(UITestCategories.ListView)]
[Category(UITestCategories.Cells)]
#endif

[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 46363, "TapGestureRecognizer blocks List View Context Actions", PlatformAffected.Android)]
public class Bugzilla46363 : TestContentPage
{
const string Target = "Two";
const string ContextAction = "Context Action";
const string TapSuccess = "Tap Success";
const string TapFailure = "Tap command executed more than once";
const string ContextSuccess = "Context Menu Success";
const string Testing = "Testing";

Expand All @@ -25,7 +32,7 @@ public class Bugzilla46363 : TestContentPage

protected override void Init()
{
var list = new List<string> { "One", Target, "Two", "Three" };
var list = new List<string> { "One", Target, "Three", "Four" };

var lv = new ListView
{
Expand All @@ -38,7 +45,15 @@ protected override void Init()

s_tapCommand = new Command(() =>
{
result.Text = TapSuccess;
if (result.Text == TapSuccess || result.Text == TapFailure)
{
// We want this test to fail if the tap command is executed more than once
result.Text = TapFailure;
}
else
{
result.Text = TapSuccess;
}
});

s_contextCommand = new Command(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected override void Init()

#if UITEST
[Test]
public void Issue1Test()
public void GridIsEnabled()
{
RunningApp.WaitForElement(q => q.Marked("entry"));
RunningApp.Tap(q => q.Marked("entry"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;

#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif

[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 55912, "Tap event not always propagated to containing Grid/StackLayout",
PlatformAffected.Android)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System;
#if UITEST
using Xamarin.UITest;
using Xamarin.Forms.Core.UITests;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 57515, "PinchGestureRecognizer not getting called on Android ", PlatformAffected.Android)]
public class Bugzilla57515 : TestContentPage
{
const string ZoomImage = "zoomImg";
const string ZoomContainer = "zoomContainer";

protected override void Init()
{
var layout = new Grid
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition { Height = 80 },
new RowDefinition { Height = GridLength.Star }
}
};

var scaleLabel = new Label();
layout.Children.Add(scaleLabel);

var pinchToZoomContainer = new PinchToZoomContainer
{
Margin = new Thickness(80),
AutomationId = ZoomContainer,
Content = new Image
{
AutomationId = ZoomImage,
Source = ImageSource.FromFile("oasis.jpg")
}
};

Grid.SetRow(pinchToZoomContainer, 1);
layout.Children.Add(pinchToZoomContainer);

scaleLabel.BindingContext = pinchToZoomContainer;
scaleLabel.SetBinding(Label.TextProperty, new Binding("CurrentScale"));

Content = layout;
}

class PinchToZoomContainer : ContentView
{
public static readonly BindableProperty CurrentScaleProperty =
BindableProperty.Create("CurrentScale", typeof(double), typeof(PinchToZoomContainer), 1.0);

public double CurrentScale
{
get { return (double)GetValue(CurrentScaleProperty); }
set { SetValue(CurrentScaleProperty, value); }
}

double startScale = 1;
double xOffset = 0;
double yOffset = 0;

public PinchToZoomContainer()
{
var pinchGesture = new PinchGestureRecognizer();
pinchGesture.PinchUpdated += OnPinchUpdated;
GestureRecognizers.Add(pinchGesture);
}

void OnPinchUpdated(object sender, PinchGestureUpdatedEventArgs e)
{
if (e.Status == GestureStatus.Started)
{
// Store the current scale factor applied to the wrapped user interface element,
// and zero the components for the center point of the translate transform.
startScale = Content.Scale;
Content.AnchorX = 0;
Content.AnchorY = 0;
}
if (e.Status == GestureStatus.Running)
{
// Calculate the scale factor to be applied.
CurrentScale += (e.Scale - 1) * startScale;
CurrentScale = Math.Max(1, CurrentScale);

// The ScaleOrigin is in relative coordinates to the wrapped user interface element,
// so get the X pixel coordinate.
double renderedX = Content.X + xOffset;
double deltaX = renderedX / Width;
double deltaWidth = Width / (Content.Width * startScale);
double originX = (e.ScaleOrigin.X - deltaX) * deltaWidth;

// The ScaleOrigin is in relative coordinates to the wrapped user interface element,
// so get the Y pixel coordinate.
double renderedY = Content.Y + yOffset;
double deltaY = renderedY / Height;
double deltaHeight = Height / (Content.Height * startScale);
double originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight;

// Calculate the transformed element pixel coordinates.
double targetX = xOffset - (originX * Content.Width) * (CurrentScale - startScale);
double targetY = yOffset - (originY * Content.Height) * (CurrentScale - startScale);

// Apply translation based on the change in origin.
Content.TranslationX = targetX.Clamp(-Content.Width * (CurrentScale - 1), 0);
Content.TranslationY = targetY.Clamp(-Content.Height * (CurrentScale - 1), 0);

// Apply scale factor
Content.Scale = CurrentScale;
}
if (e.Status == GestureStatus.Completed)
{
// Store the translation delta's of the wrapped user interface element.
xOffset = Content.TranslationX;
yOffset = Content.TranslationY;
}
}
}

#if UITEST
[Test]
public void Bugzilla57515Test()
{
RunningApp.WaitForElement(ZoomContainer);
RunningApp.WaitForElement("1");
RunningApp.PinchToZoomIn(ZoomContainer);
RunningApp.WaitForNoElement("1"); // The scale should have changed during the zoom
}
#endif
}

public static class DoubleExtensions
{
public static double Clamp(this double self, double min, double max)
{
return Math.Min(max, Math.Max(self, min));
}
}
}
Loading