Skip to content

Commit

Permalink
test: Validate touch scrolling speed
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Dec 12, 2024
1 parent 546946c commit c6d0673
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,43 @@ public async Task When_SCP_Content_EmptySized_WithMargin_LayoutCycle()
await UITestHelper.Load(SUT, x => x.IsLoaded);
}

[TestMethod]
#if !HAS_INPUT_INJECTOR
[Ignore("InputInjector is not supported on this platform.")]
#endif
public async Task When_ScrollViewer_Touch_Scrolled()
{
var stackPanel = new StackPanel();
var random = Random.Shared;
for (int i = 0; i < 10; i++)
{
stackPanel.Children.Add(
new Rectangle()
{
Width = 50,
Height = 50,
Fill = new SolidColorBrush(Color.FromArgb(255, (byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256)))
});
}

var SUT = new ScrollViewer
{
Height = 300,
Content = stackPanel
};

await UITestHelper.Load(SUT);

var input = InputInjector.TryCreate() ?? throw new InvalidOperationException("Pointer injection not available on this platform.");
using var finger = input.GetFinger();
var bounds = SUT.GetAbsoluteBounds();
finger.Press(bounds.GetCenter());
finger.MoveTo(bounds.GetCenter().Offset(0, -50));
finger.Release();
await WindowHelper.WaitForIdle();
Assert.AreEqual(50, SUT.VerticalOffset);
}

[TestMethod]
public async Task When_Zero_Size_With_Margin()
{
Expand Down

0 comments on commit c6d0673

Please sign in to comment.