Skip to content

Commit

Permalink
fix: Refactored LoggingSelectionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsashah45 committed Aug 26, 2024
1 parent 77ad90b commit f86a6b0
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Windows.Foundation;
using Windows.UI.Input.Preview.Injection;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using System.Linq;

namespace Uno.UI.RuntimeTests.Tests.Microsoft_UI_Xaml_Controls
Expand All @@ -17,22 +16,20 @@ public class Given_ListView
[TestMethod]
[RunsOnUIThread]
#if !HAS_INPUT_INJECTOR
[Ignore("InputInjector is only supported on Skia #14948")]
[Ignore("InputInjector is not supported on this platform.")]
#endif
public async Task When_ItemClicked_SelectsCorrectIndex()
{
var items = new object[] { "Item 1", "Item 2", "Item 3" };
var loggingSelectionInfo = new LoggingSelectionInfo(items, false, null);
var loggingSelectionInfo = new LoggingSelectionInfo(items);
var listViewBase = new ListView
{
ItemsSource = items,
ItemsSource = loggingSelectionInfo,
};

TestServices.WindowHelper.WindowContent = listViewBase;
await TestServices.WindowHelper.WaitForLoaded(listViewBase);

loggingSelectionInfo.SafeMoveCurrentToPosition(0);

// We don't use ActualWidth because of https://github.com/unoplatform/uno/issues/15982
var tapTarget = listViewBase.TransformToVisual(null).TransformPoint(new Point(112 * 0.9, listViewBase.ActualHeight / 2));
var injector = InputInjector.TryCreate() ?? throw new InvalidOperationException("Failed to init the InputInjector");
Expand All @@ -42,6 +39,7 @@ public async Task When_ItemClicked_SelectsCorrectIndex()
finger.Release();

Assert.AreEqual(0, listViewBase.SelectedIndex);
Assert.IsTrue(loggingSelectionInfo.IsSelected(0), "The item at index 0 should be selected.");
Assert.IsTrue(loggingSelectionInfo.MethodLog.All(m => !m.Contains("MoveCurrent", StringComparison.OrdinalIgnoreCase)));
}
}
Expand Down
Loading

0 comments on commit f86a6b0

Please sign in to comment.