Skip to content

[Testing] Feature matrix UITest Cases for Editor Control #30574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Added sample and test files
  • Loading branch information
LogishaSelvarajSF4525 committed Jul 11, 2025
commit 46ba7fb223451473cf29df32dadce910d890a785
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
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
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
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
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
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
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
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
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
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
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
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public override string ToString()
new GalleryPageFactory(() => new ImageControlPage(), "Image Feature Matrix"),
new GalleryPageFactory(() => new ImageButtonControlPage(), "ImageButton Feature Matrix"),
new GalleryPageFactory(() => new BoxViewControlPage(), "BoxView Feature Matrix"),
new GalleryPageFactory(() => new EditorControlPage(), "Editor Feature Matrix"),
};

public CorePageView(Page rootPage)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Maui.Controls.Sample"
x:DataType="local:EditorViewModel"
x:Class="Maui.Controls.Sample.EditorControlMainPage">
<VerticalStackLayout Padding="20"
Spacing="8">
<Label Text="Editor Control"
FontSize="20" Margin="0,0,0,50"
HorizontalOptions="Center"/>

<local:UITestEditor x:Name="EditorControl"
IsCursorVisible="False"
Text="{Binding Text}"
Placeholder="{Binding Placeholder}"
PlaceholderColor="{Binding PlaceholderColor}"
TextColor="{Binding TextColor}"
HorizontalTextAlignment="{Binding HorizontalTextAlignment}"
VerticalTextAlignment="{Binding VerticalTextAlignment}"
FontSize="{Binding FontSize}"
CharacterSpacing="{Binding CharacterSpacing}"
IsReadOnly="{Binding IsReadOnly}"
IsTextPredictionEnabled="{Binding IsTextPredictionEnabled}"
IsSpellCheckEnabled="{Binding IsSpellCheckEnabled}"
Shadow="{Binding EditorShadow}"
MaxLength="{Binding MaxLength}"
SelectionLength="{Binding SelectionLength}"
CursorPosition="{Binding CursorPosition, Mode=TwoWay}"
Keyboard="{Binding Keyboard}"
FontFamily="{Binding FontFamily}"
IsVisible="{Binding IsVisible}"
IsEnabled="{Binding IsEnabled}"
FlowDirection="{Binding FlowDirection}"
HeightRequest="{Binding HeightRequest}"
FontAttributes="{Binding FontAttributes}"
TextTransform="{Binding TextTransform}"
AutoSize ="{Binding AutoSizeOption}"
TextChanged="EditorControl_TextChanged"
Completed="EditorControl_Completed"
Focused="EditorControl_Focused"
Unfocused="EditorControl_Unfocused"
AutomationId="TestEditor"/>

<Grid HeightRequest="130"/>

<Grid ColumnSpacing="10" Margin="0,10,0,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<!-- Row 1: Labels -->
<Label Text="Selection Length:"
FontSize="11"
Grid.Row="0"
Grid.Column="0"/>
<Label Text="Cursor position:"
FontSize="11"
Grid.Row="0"
Grid.Column="1"/>

<!-- Row 2: Entries -->
<local:UITestEntry x:Name="SelectionLengthEntry"
Text="{Binding SelectionLength}"
AutomationId="SelectionLengthEntry"
IsCursorVisible="False"
TextChanged="SelectionLength_Clicked"
Grid.Row="1"
Grid.Column="0"/>
<local:UITestEntry x:Name="CursorPositionEntry"
Text="{Binding CursorPosition}"
AutomationId="CursorPositionEntry"
IsCursorVisible="False"
Grid.Row="1"
Grid.Column="1"/>
</Grid>

<Button Text="Update Cursor Selection"
FontSize="11"
Clicked="OnUpdateCursorAndSelectionClicked"
AutomationId="UpdateCursorAndSelectionButton"/>

<Label Text="Events:"
FontSize="11"/>
<Label x:Name="TextChangedLabel"
Text="{Binding TextChangedText}"
AutomationId="TextChangedLabel"
FontSize="11"/>
<Label x:Name="CompletedLabel"
Text="{Binding CompletedText}"
AutomationId="CompletedLabel"
FontSize="11"/>
<Label x:Name="FocusedLabel"
Text="{Binding FocusedText}"
AutomationId="FocusedLabel"
FontSize="11"/>
<Label x:Name="UnfocusedLabel"
Text="{Binding UnfocusedText}"
AutomationId="UnfocusedLabel"
FontSize="11"/>
</VerticalStackLayout>

<ContentPage.ToolbarItems>
<ToolbarItem Text="Options"
Clicked="NavigateToOptionsPage_Clicked"></ToolbarItem>
</ContentPage.ToolbarItems>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System.ComponentModel;
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample;

public class EditorControlPage : NavigationPage
{
private EditorViewModel _viewModel;

public EditorControlPage()
{
_viewModel = new EditorViewModel();
PushAsync(new EditorControlMainPage(_viewModel));
}
}

public partial class EditorControlMainPage : ContentPage
{
private EditorViewModel _viewModel;

public EditorControlMainPage(EditorViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
EditorControl.PropertyChanged += UpdateEditorControl;
}

private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new EditorViewModel();
_viewModel.Text = "Test Editor";
_viewModel.Placeholder = "Enter text here";
_viewModel.VerticalTextAlignment = TextAlignment.End;
_viewModel.CursorPosition = 0;
_viewModel.SelectionLength = 0;
await Navigation.PushAsync(new EditorOptionsPage(_viewModel));
}

private void CursorPositionButton_Clicked(object sender, EventArgs e)
{
if (int.TryParse(CursorPositionEntry.Text, out int cursorPosition))
{
_viewModel.CursorPosition = cursorPosition;
}
}

private void SelectionLength_Clicked(object sender, EventArgs e)
{
if (int.TryParse(SelectionLengthEntry.Text, out int selectionLength))
{
_viewModel.SelectionLength = selectionLength;
}
}

private void OnUpdateCursorAndSelectionClicked(object sender, EventArgs e)
{
if (int.TryParse(CursorPositionEntry.Text, out int cursorPosition))
{
EditorControl.Focus();
EditorControl.CursorPosition = cursorPosition;

if (BindingContext is EditorViewModel vm)
vm.CursorPosition = cursorPosition;
}

if (int.TryParse(SelectionLengthEntry.Text, out int selectionLength))
{
EditorControl.Focus();
EditorControl.SelectionLength = selectionLength;

if (BindingContext is EditorViewModel vm)
vm.SelectionLength = selectionLength;
}
CursorPositionEntry.Text = EditorControl.CursorPosition.ToString();
SelectionLengthEntry.Text = EditorControl.SelectionLength.ToString();
}

void UpdateEditorControl(object sender, PropertyChangedEventArgs args)
{
if (args.PropertyName == Editor.CursorPositionProperty.PropertyName)
CursorPositionEntry.Text = EditorControl.CursorPosition.ToString();
else if (args.PropertyName == Editor.SelectionLengthProperty.PropertyName)
SelectionLengthEntry.Text = EditorControl.SelectionLength.ToString();
}

private void EditorControl_TextChanged(object sender, TextChangedEventArgs e)
{
string eventInfo = $"TextChanged: Old='{e.OldTextValue}', New='{e.NewTextValue}'";

if (BindingContext is EditorViewModel vm)
{
vm.TextChangedText = eventInfo;
}
}

private void EditorControl_Completed(object sender, EventArgs e)
{
string eventInfo = $"Completed: Event Triggered";

if (BindingContext is EditorViewModel vm)
{
vm.CompletedText = eventInfo;
}
}

private void EditorControl_Focused(object sender, FocusEventArgs e)
{
string eventInfo = $"Focused: Event Triggered";

if (BindingContext is EditorViewModel vm)
{
vm.FocusedText = eventInfo;
}
}

private void EditorControl_Unfocused(object sender, FocusEventArgs e)
{
string eventInfo = $"Unfocused: Event Triggered";

if (BindingContext is EditorViewModel vm)
{
vm.UnfocusedText = eventInfo;
}
}
}
Loading