Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -58,7 +58,7 @@ private void OnScrollToButtonClicked(object sender, EventArgs e)
if (int.TryParse(scrollToIndexEntry.Text, out int index) &&
index >= 0 && index < carouselView.ItemsSource.Cast<object>().Count())
{
carouselView.ScrollTo(index);
carouselView.ScrollTo(index, animate: false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
x:Class="Maui.Controls.Sample.CarouselViewOptionsPage"
Title="CarouselViewOptionsPage">

<ContentPage.ToolbarItems>
<ToolbarItem Text="Apply"
Clicked="ApplyButton_Clicked"
AutomationId="Apply"/>
</ContentPage.ToolbarItems>

<ScrollView>
<!-- <StackLayout Padding="20"> -->
<Grid Padding="1"
RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto">

<StackLayout Grid.Row="1"
Padding="1">

<!-- Apply Button -->
<Button Text="Apply"
Clicked="ApplyButton_Clicked"
HorizontalOptions="Center"
AutomationId="Apply"/>

<!-- Items Source -->
<Label Text="ItemsSource"
FontAttributes="Bold"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,24 @@ public void DropEventCoordinates()

App.WaitForElement("Blue");
App.WaitForElement("Green");
App.DragAndDrop("Blue", "Green");

// Wait for all UI elements to confirm drag and drop operation completion
App.WaitForElement("DropRelativeLayout");
App.WaitForElement("DropRelativeScreen");
App.WaitForElement("DropRelativeLabel");
App.WaitForElement("DragStartRelativeScreen");
bool dragDropSuccess = false;
for (int i = 0; i < 3; i++)
{
App.DragAndDrop("Blue", "Green");
Thread.Sleep(500);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Thread.Sleep(500) is a code smell in UI tests. This hard-coded delay can cause tests to be slower than necessary or still fail if the UI isn't ready. Consider using App.WaitForElement or similar waiting mechanisms that poll for the expected state instead of arbitrary waits.

Suggested change
Thread.Sleep(500);

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 500 (milliseconds) should be extracted to a named constant (e.g., const int DragDropDelayMs = 500) to improve code readability and make it easier to adjust timing if needed.

Copilot uses AI. Check for mistakes.
App.WaitForElement("DropRelativeLayout");
if (GetCoordinatesFromLabel(App.FindElement("DropRelativeLayout").GetText()) != null)
{
dragDropSuccess = true;
break;
}
}

if (!dragDropSuccess)
{
Assert.Fail("Drag-and-drop operation failed after many attempts. Drop event did not fire.");
}

var dropRelativeToLayout = GetCoordinatesFromLabel(App.FindElement("DropRelativeLayout").GetText());
var dropRelativeToScreen = GetCoordinatesFromLabel(App.FindElement("DropRelativeScreen").GetText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,17 @@ public void VerifyCarouselViewWithScrollTo()
App.EnterText(ScrollToIndexEntry, "3");
App.WaitForElement(ScrollToButton);
App.Tap(ScrollToButton);
#if IOS //In CI CarouselView ScrollTo sometimes scrolls to wrong item
try
{
App.WaitForElement("Item 4");
}
catch (TimeoutException)
{
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry logic silently catches and retries on failure without logging. If this iOS-specific flakiness continues, there will be no diagnostic information in test logs to understand why the retry was needed or if the retry mechanism itself is working. Consider adding a log statement or test output when the retry is triggered.

Suggested change
{
{
TestContext.WriteLine("VerifyCarouselViewWithScrollTo: initial ScrollTo did not reach 'Item 4' within the timeout on iOS; retrying ScrollToButton tap.");

Copilot uses AI. Check for mistakes.
App.WaitForElement(ScrollToButton);
App.Tap(ScrollToButton);
}
#endif
App.WaitForElement("Item 4");
}

Expand Down
Loading