Skip to content
Open
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
@@ -0,0 +1,47 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 32825, "MauiDoneAccessoryView DoneButton should be accessible for UI testing", PlatformAffected.iOS)]
public class MauiDoneAccessoryButton : TestContentPage
{
protected override void Init()
{
var entry = new Entry
{
AutomationId = "NumericEntry",
Keyboard = Keyboard.Numeric,
Placeholder = "Tap here to show numeric keyboard with Done button"
};

var label = new Label
{
AutomationId = "ResultLabel",
Text = "Waiting for entry to be focused"
};

entry.Focused += (s, e) =>
{
label.Text = "Entry focused - Done button should be accessible";
};

entry.Completed += (s, e) =>
{
label.Text = "Entry completed - Done button was tapped";
};

Content = new VerticalStackLayout
{
Padding = new Thickness(20),
Spacing = 10,
Children =
{
new Label
{
Text = "This test verifies that the Done button on numeric keyboards has an accessibility identifier for UI testing.",
Margin = new Thickness(0, 0, 0, 20)
},
entry,
label
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if IOS // MauiDoneAccessoryView is iOS only
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class MauiDoneAccessoryButton : _IssuesUITest
{
const string DoneButtonAutomationId = "Microsoft.Maui.Platform.MauiDoneAccessory.DoneButton";

public MauiDoneAccessoryButton(TestDevice device) : base(device)
{
}

public override string Issue => "MauiDoneAccessoryView DoneButton should be accessible for UI testing";

[Test]
[Category(UITestCategories.Entry)]
public void DoneButtonShouldHaveAccessibilityIdentifier()
{
// Wait for the entry to be ready
App.WaitForElement("NumericEntry");

// Tap the entry to bring up the keyboard
App.Tap("NumericEntry");

// Wait for the Done button to appear in the keyboard accessory view
var doneButton = App.WaitForElement(DoneButtonAutomationId);

// Verify the Done button exists and is accessible
Assert.That(doneButton, Is.Not.Null, "Done button should be accessible via its automation ID");

// Tap the Done button
App.Tap(DoneButtonAutomationId);

// Verify the completed event was triggered
var result = App.FindElement("ResultLabel").GetText();
Assert.That(result, Does.Contain("completed"), "Done button tap should trigger entry completion");
}
}
#endif
3 changes: 3 additions & 0 deletions src/Core/src/Platform/iOS/MauiDoneAccessoryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Microsoft.Maui.Platform
{
internal class MauiDoneAccessoryView : UIToolbar
{
const string DoneButtonAutomationId = "Microsoft.Maui.Platform.MauiDoneAccessory.DoneButton";
readonly BarButtonItemProxy _proxy;

public MauiDoneAccessoryView() : base(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, 44))
Expand All @@ -16,6 +17,7 @@ public MauiDoneAccessoryView() : base(new CGRect(0, 0, UIScreen.MainScreen.Bound
Translucent = true;
var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, _proxy.OnDataClicked);
doneButton.AccessibilityIdentifier = DoneButtonAutomationId;

SetItems(new[] { spacer, doneButton }, false);
}
Expand All @@ -33,6 +35,7 @@ public MauiDoneAccessoryView(Action doneClicked) : base(new CGRect(0, 0, UIScree

var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, _proxy.OnClicked);
doneButton.AccessibilityIdentifier = DoneButtonAutomationId;
SetItems(new[] { spacer, doneButton }, false);
}

Expand Down
Loading