Skip to content

Commit

Permalink
test(pointers): Test the translate X manipulation in ListView
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Aug 19, 2021
1 parent aa0d67f commit 245ae57
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ public void Manipulation_WithNestedElement()
Assert.IsTrue(result.Contains("[PARENT] Manip delta[CHILD] Pointer moved[PARENT] Manip delta[CHILD] Pointer moved"));
}

[Test]
[AutoRetry]
[ActivePlatforms(Platform.Android, Platform.iOS)] // Touch only test
public void Manipulation_WhenInListViewAndManipulationTranslateX_ThenAbort()
{
Run("UITests.Windows_UI_Input.GestureRecognizerTests.Manipulation_WhenInListView");

var scroller = _app.WaitForElement("ItemsSupportsTranslateX").Single().Rect;

_app.DragCoordinates(scroller.CenterX, scroller.Bottom - 5, scroller.CenterX, scroller.Y + 10);

var result = TakeScreenshot("after_scroll", ignoreInSnapshotCompare: true);

ImageAssert.DoesNotHaveColorAt(result, scroller.CenterX, scroller.Y + 10, "#FF0000");
}

[Test]
[AutoRetry]
[ActivePlatforms(Platform.Android, Platform.iOS)]
Expand Down
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Input\GestureRecognizerTests\Manipulation_WhenInListView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Input\GestureRecognizerTests\Manipulation_WhenInScrollViewer.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -4632,6 +4636,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Input\GestureRecognizerTests\Manipulation_Inertia.xaml.cs">
<DependentUpon>Manipulation_Inertia.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Input\GestureRecognizerTests\Manipulation_WhenInListView.xaml.cs">
<DependentUpon>Manipulation_WhenInListView.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Input\GestureRecognizerTests\Manipulation_WhenInScrollViewer.xaml.cs">
<DependentUpon>Manipulation_WhenInScrollViewer.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Page
x:Class="UITests.Windows_UI_Input.GestureRecognizerTests.Manipulation_WhenInListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Input.GestureRecognizerTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<Border Height="504" Width="204" BorderBrush="Black" BorderThickness="2">
<ListView x:Name="ItemsSupportsTranslateX">
<ListView.ItemTemplate>
<DataTemplate>
<Border Height="200" Width="200" Background="{Binding}" ManipulationMode="TranslateX" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Uno.UI.Samples.Controls;

namespace UITests.Windows_UI_Input.GestureRecognizerTests
{
[Sample(
"Gesture recognizer", "ListView",
Description = "Automated test which validates if vertical scrolling of ListView works properly even if items does handles some manipulations.",
IgnoreInSnapshotTests = true)]
public sealed partial class Manipulation_WhenInListView : Page
{
public Manipulation_WhenInListView()
{
this.InitializeComponent();

ItemsSupportsTranslateX.ItemsSource = new[] { "#FF0000", "#FF8000", "#FFFF00", "#008000", "#0000FF", "#A000C0" };
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public partial class NativeListViewBase : UnoRecyclerView, ILayoutConstraints
/// </summary>
private bool _isInAnimatedScroll;

bool _shouldRecalibrateFlingVelocity;
float? _previousX, _previousY;
float? _deltaX, _deltaY;
private ScrollBarVisibility? _horizontalScrollBarVisibility;
private ScrollBarVisibility? _verticalScrollBarVisibility;
private bool _shouldRecalibrateFlingVelocity;
private float? _previousX, _previousY;
private float? _deltaX, _deltaY;

internal BufferViewCache ViewCache { get; }

Expand Down Expand Up @@ -125,13 +127,10 @@ public Thickness Padding

public ScrollBarVisibility HorizontalScrollBarVisibility
{
get
{
return HorizontalScrollBarEnabled ? ScrollBarVisibility.Visible : ScrollBarVisibility.Disabled;
}

get => _horizontalScrollBarVisibility ?? (HorizontalScrollBarEnabled ? ScrollBarVisibility.Visible : ScrollBarVisibility.Disabled);
set
{
_horizontalScrollBarVisibility = value;
switch (value)
{
case ScrollBarVisibility.Disabled:
Expand All @@ -149,13 +148,10 @@ public ScrollBarVisibility HorizontalScrollBarVisibility

public ScrollBarVisibility VerticalScrollBarVisibility
{
get
{
return VerticalScrollBarEnabled ? ScrollBarVisibility.Visible : ScrollBarVisibility.Disabled;
}

get => _verticalScrollBarVisibility ?? (VerticalScrollBarEnabled ? ScrollBarVisibility.Visible : ScrollBarVisibility.Disabled);
set
{
_verticalScrollBarVisibility = value;
switch (value)
{
case ScrollBarVisibility.Disabled:
Expand Down

0 comments on commit 245ae57

Please sign in to comment.