From c2102552b250a91e629e392b0c2909faae9c0175 Mon Sep 17 00:00:00 2001 From: Jakub Florkowski Date: Fri, 13 Nov 2026 14:25:17 +0100 Subject: [PATCH] [Testing] Assert first-item semantics for KeepItemsInView Share the positive first-item oracle across Android and Apple. Scroll away again after the first insertion and verify the first item after the remaining updates, preserving 25 total insertions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- ...s.CollectionViewItemsUpdatingScrollMode.cs | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/CollectionViewUITests.CollectionViewItemsUpdatingScrollMode.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/CollectionViewUITests.CollectionViewItemsUpdatingScrollMode.cs index e1f91c593034..3704d8dfae5f 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/CollectionViewUITests.CollectionViewItemsUpdatingScrollMode.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/CollectionViewUITests.CollectionViewItemsUpdatingScrollMode.cs @@ -16,42 +16,31 @@ public CollectionViewItemsUpdatingScrollModeUITests(TestDevice device) protected override bool ResetAfterEachTest => true; #if TEST_FAILS_ON_WINDOWS // For more information, see :https://github.com/dotnet/maui/issues/28006 -#if ANDROID [Test] [ShardedTestCategory(UITestCategories.CollectionView, shard: 5)] public void KeepItemsInView() { App.WaitForElement("ScrollToMiddle"); App.Click("ScrollToMiddle"); - App.WaitForElement("Vegetables.jpg, 10"); + Assert.That(App.WaitForElement("Vegetables.jpg, 10").IsDisplayed(), Is.True); - for (int n = 0; n < 25; n++) - { - App.WaitForElement("AddItemAbove"); - App.Tap("AddItemAbove"); - } + App.WaitForElement("AddItemAbove"); + App.Tap("AddItemAbove"); + Assert.That(App.WaitForElement("cover1.jpg, 0").IsDisplayed(), Is.True); - App.WaitForNoElement("Vegetables.jpg, 10"); - } - -#else - [Test] - [ShardedTestCategory(UITestCategories.CollectionView, shard: 5)] - public void KeepItemsInView() - { - App.WaitForElement("ScrollToMiddle"); + // AddItemAbove inserts before the midpoint, so item 9 is now at index 10. App.Click("ScrollToMiddle"); - App.WaitForElement("Vegetables.jpg, 10"); + Assert.That(App.WaitForElement("photo.jpg, 9").IsDisplayed(), Is.True); - for (int n = 0; n < 25; n++) + for (int n = 0; n < 24; n++) { - App.Click("AddItemAbove"); + App.WaitForElement("AddItemAbove"); + App.Tap("AddItemAbove"); } - App.WaitForElement("Vegetables.jpg, 10"); + Assert.That(App.WaitForElement("cover1.jpg, 0").IsDisplayed(), Is.True); } #endif -#endif #if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST // The test fails on iOS and macOS because Appium is unable to locate the Picker control elements resulting in a TimeoutException. For more information, see: https://github.com/dotnet/maui/issues/28024 // KeepScrollOffset (src\Compatibility\ControlGallery\src\Issues.Shared\CollectionViewItemsUpdatingScrollMode.cs)