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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19500.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#if MACCATALYST
using UIKit;
using Microsoft.Maui.Platform;
#endif

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 19500, "[iOS] Editor is not be able to scroll if IsReadOnly is true", PlatformAffected.iOS)]
public partial class Issue19500 : TestContentPage
{
const string BaseEditorText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla porttitor mauris non ornare ultrices. Ut semper ultrices justo eget semper.Ut imperdiet dolor ut vestibulum molestie. Duis a libero ex. Etiam mi urna, lobortis sed tincidunt in, tempus eget magna. Aenean quis malesuada eros. Phasellus felis eros, condimentum et tortor sed, condimentum convallis turpis. Sed in varius metus, at auctor orci. Maecenas luctus nibh nibh, nec aliquam est fermentum in. Etiam consectetur lectus erat, sed placerat sapien rutrum eu. Suspendisse tincidunt fermentum tempor.Maecenas egestas neque nec lacinia fringilla.";

protected override void Init()
{
var rootLayout = new VerticalStackLayout
{
Spacing = 10,
Padding = 10
};

var descriptionLabel = CreateLabel(
"This test case is to verify that the Editor is scrollable when IsReadOnly is set to true.",
"descriptionLabel");

var yPositionLabel = CreateLabel("0", "yPositionLabel");

var editor = CreateEditor(yPositionLabel);

rootLayout.Children.Add(descriptionLabel);
rootLayout.Children.Add(editor);
rootLayout.Children.Add(yPositionLabel);

Content = rootLayout;
}

Label CreateLabel(string text, string automationId) =>
new Label
{
Text = text,
AutomationId = automationId
};

Editor CreateEditor(Label yPositionLabel)
{
var editor = new Editor
{
HeightRequest = 100,
IsReadOnly = true,
AutomationId = "editor",
Text = GetEditorText()
};

#if MACCATALYST
editor.HandlerChanged += (_, _) =>
{
if (editor.Handler?.PlatformView is MauiTextView mauiTextView)
{
mauiTextView.Scrolled += (s, e) =>
{
if (s is UIScrollView scrollView)
{
yPositionLabel.Text = scrollView.ContentOffset.Y.ToString();
}
};
}
};
#endif

return editor;
}

private string GetEditorText()
{
#if MACCATALYST
return BaseEditorText + " " + BaseEditorText;
#else
return BaseEditorText;
#endif
}
}
14 changes: 0 additions & 14 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19500.xaml

This file was deleted.

15 changes: 0 additions & 15 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19500.xaml.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
#if TEST_FAILS_ON_CATALYST // Since this test verifies the scrolling behavior in the editor control and the App.ScrollDown function is inconsistent, relying on screenshot verification causes flakiness in CI. It needs to be validated using an alternative approach, or else it would be better to consider this for manual testing.
// Issue for reenable: https://github.com/dotnet/maui/issues/29025
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue19500 : _IssuesUITest
{
public class Issue19500 : _IssuesUITest
{
public override string Issue => "[iOS] Editor is not be able to scroll if IsReadOnly is true";
public override string Issue => "[iOS] Editor is not be able to scroll if IsReadOnly is true";

public Issue19500(TestDevice device) : base(device)
{
}
const string yPositionLabel = "yPositionLabel";

[Test]
[Category(UITestCategories.Editor)]
public void TextInEditorShouldScroll()
{
_ = App.WaitForElement("editor");
App.ScrollDown("editor");
public Issue19500(TestDevice device) : base(device)
{
}

// The test passes if the text inside the editor scrolls down
VerifyScreenshot();
}
[Test]
[Category(UITestCategories.Editor)]
public void TextInEditorShouldScroll()
{
var yPosLabel = App.WaitForElement(yPositionLabel);
App.ScrollDown("editor");
#if MACCATALYST
App.ScrollDown("editor"); // To make sure the editor is scrolled down
var yPos = yPosLabel.GetText();
Assert.That(yPos,Is.GreaterThan("0")); // The Y position should be greater than 0 after scrolling down
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a note — since this is a UITest, ideally we should verify that scrolling is visually reflected in the UI. Relying on ContentOffset.Y > 0 introduces a logical check, but it doesn’t fully guarantee a visible change occurred on screen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bhavanesh2001 , The test is to check whether the editor is scrollable or not. The previous UI test was flaky because the content was scrolled a pixel off from its original position. So instead of relying on a visual confirmation, I went with an alternative approach. The Y position label text will be updated only if the editor is scrolled. Otherwise it stays as 0.

This is added only to MAC to resolve flaky issue on CI.

#else
// The test passes if the text inside the editor scrolls down
VerifyScreenshot();
#endif
}
}
#endif
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading