From 8baa5cd0ca1f1b87ac36f87b6593446a3c00e4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Sua=CC=81rez=20Ruiz?= Date: Thu, 8 Apr 2021 16:12:38 +0200 Subject: [PATCH 1/4] Implement Keyboard property in EditorHandlers --- .../Handlers/Editor/EditorHandler.Android.cs | 5 + .../Handlers/Editor/EditorHandler.Standard.cs | 1 + .../Handlers/Editor/EditorHandler.Windows.cs | 3 + src/Core/src/Handlers/Editor/EditorHandler.cs | 1 + .../src/Handlers/Editor/EditorHandler.iOS.cs | 5 + .../Platform/Android/EditTextExtensions.cs | 36 ++++++ .../src/Platform/iOS/TextViewExtensions.cs | 19 +++ .../Editor/EditorHandlerTests.Android.cs | 50 ++++++++ .../Handlers/Editor/EditorHandlerTests.cs | 108 ++++++++++++++++++ .../Handlers/Editor/EditorHandlerTests.iOS.cs | 30 +++++ 10 files changed, 258 insertions(+) diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Android.cs b/src/Core/src/Handlers/Editor/EditorHandler.Android.cs index 86d980dc271e..3ae0b72be44d 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Android.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Android.cs @@ -76,5 +76,10 @@ public static void MapFont(EditorHandler handler, IEditor editor) [MissingMapper] public static void MapTextColor(EditorHandler handler, IEditor editor) { } + + public static void MapKeyboard(EditorHandler handler, IEditor editor) + { + handler.NativeView?.UpdateKeyboard(editor); + } } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Standard.cs b/src/Core/src/Handlers/Editor/EditorHandler.Standard.cs index 1766b7bba0af..b4c86ab939b3 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Standard.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Standard.cs @@ -15,5 +15,6 @@ public static void MapIsTextPredictionEnabled(EditorHandler handler, IEditor edi public static void MapFont(IViewHandler handler, IEditor editor) { } public static void MapIsReadOnly(IViewHandler handler, IEditor editor) { } public static void MapTextColor(EditorHandler handler, IEditor editor) { } + public static void MapKeyboard(EditorHandler handler, IEditor editor) { } } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs index 60af8598643c..8ac1d31a0795 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs @@ -33,5 +33,8 @@ public static void MapIsReadOnly(IViewHandler handler, IEditor editor) { } [MissingMapper] public static void MapTextColor(EditorHandler handler, IEditor editor) { } + + [MissingMapper] + public static void MapKeyboard(EditorHandler handler, IEditor editor) { } } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Editor/EditorHandler.cs b/src/Core/src/Handlers/Editor/EditorHandler.cs index 28b8a0fceacb..da6411abee7b 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.cs @@ -13,6 +13,7 @@ public partial class EditorHandler [nameof(IEditor.PlaceholderColor)] = MapPlaceholderColor, [nameof(IEditor.Text)] = MapText, [nameof(IEditor.TextColor)] = MapTextColor, + [nameof(IEditor.Keyboard)] = MapKeyboard }; public EditorHandler() : base(EditorMapper) diff --git a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs index b6a063fc0b2b..9821cce2d54e 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs @@ -117,5 +117,10 @@ public static void MapFont(EditorHandler handler, IEditor editor) [MissingMapper] public static void MapTextColor(EditorHandler handler, IEditor editor) { } + + public static void MapKeyboard(EditorHandler handler, IEditor editor) + { + handler.NativeView?.UpdateKeyboard(editor); + } } } \ No newline at end of file diff --git a/src/Core/src/Platform/Android/EditTextExtensions.cs b/src/Core/src/Platform/Android/EditTextExtensions.cs index f07827611884..2c78adb62841 100644 --- a/src/Core/src/Platform/Android/EditTextExtensions.cs +++ b/src/Core/src/Platform/Android/EditTextExtensions.cs @@ -147,6 +147,11 @@ public static void UpdateKeyboard(this AppCompatEditText editText, IEntry entry) editText.SetInputType(entry); } + public static void UpdateKeyboard(this AppCompatEditText editText, IEditor editor) + { + editText.SetInputType(editor); + } + public static void UpdateIsReadOnly(this AppCompatEditText editText, IEditor editor) { bool isReadOnly = !editor.IsReadOnly; @@ -199,6 +204,37 @@ public static void UpdateReturnType(this AppCompatEditText editText, IEntry entr editText.ImeOptions = entry.ReturnType.ToNative(); } + internal static void SetInputType(this AppCompatEditText editText, IEditor editor) + { + if (editor.IsReadOnly) + { + editText.InputType = InputTypes.Null; + } + else + { + var keyboard = editor.Keyboard; + var nativeInputTypeToUpdate = keyboard.ToInputType(); + + if (keyboard is not CustomKeyboard) + { + // TODO: IsSpellCheckEnabled handling must be here. + + if ((nativeInputTypeToUpdate & InputTypes.TextFlagNoSuggestions) != InputTypes.TextFlagNoSuggestions) + { + if (!editor.IsTextPredictionEnabled) + nativeInputTypeToUpdate |= InputTypes.TextFlagNoSuggestions; + } + } + + if (keyboard == Keyboard.Numeric) + { + editText.KeyListener = LocalizedDigitsKeyListener.Create(editText.InputType); + } + + editText.InputType = nativeInputTypeToUpdate; + } + } + internal static void SetInputType(this AppCompatEditText editText, IEntry entry) { if (entry.IsReadOnly) diff --git a/src/Core/src/Platform/iOS/TextViewExtensions.cs b/src/Core/src/Platform/iOS/TextViewExtensions.cs index 9ed0b0f65926..70e1992580ff 100644 --- a/src/Core/src/Platform/iOS/TextViewExtensions.cs +++ b/src/Core/src/Platform/iOS/TextViewExtensions.cs @@ -46,5 +46,24 @@ public static void UpdateIsReadOnly(this UITextView textView, IEditor editor) { textView.UserInteractionEnabled = !editor.IsReadOnly; } + + public static void UpdateKeyboard(this UITextView textView, IEditor editor) + { + var keyboard = editor.Keyboard; + + textView.ApplyKeyboard(keyboard); + + if (keyboard is not CustomKeyboard) + { + // TODO: IsSpellCheckEnabled handling must be here. + + if (!editor.IsTextPredictionEnabled) + { + textView.AutocorrectionType = UITextAutocorrectionType.No; + } + } + + textView.ReloadInputViews(); + } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.Android.cs index 98e7e16f0382..04d54af32214 100644 --- a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.Android.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Android.Text; +using Android.Text.Method; using AndroidX.AppCompat.Widget; using Microsoft.Extensions.DependencyInjection; using Microsoft.Maui.DeviceTests.Stubs; @@ -99,5 +100,54 @@ double GetNativeUnscaledFontSize(EditorHandler editorHandler) var textView = GetNativeEditor(editorHandler); return textView.TextSize / textView.Resources.DisplayMetrics.Density; } + + bool GetNativeIsNumericKeyboard(EditorHandler editorHandler) + { + var textView = GetNativeEditor(editorHandler); + var inputTypes = textView.InputType; + + return textView.KeyListener is NumberKeyListener + && (inputTypes.HasFlag(InputTypes.NumberFlagDecimal) && inputTypes.HasFlag(InputTypes.ClassNumber) && inputTypes.HasFlag(InputTypes.NumberFlagSigned)); + } + + bool GetNativeIsChatKeyboard(EditorHandler editorHandler) + { + var textView = GetNativeEditor(editorHandler); + var inputTypes = textView.InputType; + + return inputTypes.HasFlag(InputTypes.ClassText) && inputTypes.HasFlag(InputTypes.TextFlagCapSentences) && inputTypes.HasFlag(InputTypes.TextFlagNoSuggestions); + } + + bool GetNativeIsEmailKeyboard(EditorHandler editorHandler) + { + var textView = GetNativeEditor(editorHandler); + var inputTypes = textView.InputType; + + return (inputTypes.HasFlag(InputTypes.ClassText) && inputTypes.HasFlag(InputTypes.TextVariationEmailAddress)); + } + + bool GetNativeIsTelephoneKeyboard(EditorHandler editorHandler) + { + var textView = GetNativeEditor(editorHandler); + var inputTypes = textView.InputType; + + return inputTypes.HasFlag(InputTypes.ClassPhone); + } + + bool GetNativeIsUrlKeyboard(EditorHandler editorHandler) + { + var textView = GetNativeEditor(editorHandler); + var inputTypes = textView.InputType; + + return inputTypes.HasFlag(InputTypes.ClassText) && inputTypes.HasFlag(InputTypes.TextVariationUri); + } + + bool GetNativeIsTextKeyboard(EditorHandler editorHandler) + { + var textView = GetNativeEditor(editorHandler); + var inputTypes = textView.InputType; + + return inputTypes.HasFlag(InputTypes.ClassText) && inputTypes.HasFlag(InputTypes.TextFlagCapSentences) && !inputTypes.HasFlag(InputTypes.TextFlagNoSuggestions); + } } } diff --git a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs index d9e512e35f07..b236fec43765 100644 --- a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs @@ -218,5 +218,113 @@ public async Task FontSizeInitializesCorrectly(int fontSize) await ValidatePropertyInitValue(editor, () => editor.Font.FontSize, GetNativeUnscaledFontSize, editor.Font.FontSize); } + + [Theory(DisplayName = "Validates Numeric Keyboard")] + [InlineData(nameof(Keyboard.Chat), false)] + [InlineData(nameof(Keyboard.Default), false)] + [InlineData(nameof(Keyboard.Email), false)] + [InlineData(nameof(Keyboard.Numeric), true)] + [InlineData(nameof(Keyboard.Plain), false)] + [InlineData(nameof(Keyboard.Telephone), false)] + [InlineData(nameof(Keyboard.Text), false)] + [InlineData(nameof(Keyboard.Url), false)] + public async Task ValidateNumericKeyboard(string keyboardName, bool expected) + { + var keyboard = (Keyboard)typeof(Keyboard).GetProperty(keyboardName).GetValue(null); + + var editor = new EditorStub() { Keyboard = keyboard }; + + await ValidatePropertyInitValue(editor, () => expected, GetNativeIsNumericKeyboard, expected); + } + + [Theory(DisplayName = "Validates Email Keyboard")] + [InlineData(nameof(Keyboard.Chat), false)] + [InlineData(nameof(Keyboard.Default), false)] + [InlineData(nameof(Keyboard.Email), true)] + [InlineData(nameof(Keyboard.Numeric), false)] + [InlineData(nameof(Keyboard.Plain), false)] + [InlineData(nameof(Keyboard.Telephone), false)] + [InlineData(nameof(Keyboard.Text), false)] + [InlineData(nameof(Keyboard.Url), false)] + public async Task ValidateEmailKeyboard(string keyboardName, bool expected) + { + var keyboard = (Keyboard)typeof(Keyboard).GetProperty(keyboardName).GetValue(null); + + var editor = new EditorStub() { Keyboard = keyboard }; + + await ValidatePropertyInitValue(editor, () => expected, GetNativeIsEmailKeyboard, expected); + } + + [Theory(DisplayName = "Validates Telephone Keyboard")] + [InlineData(nameof(Keyboard.Chat), false)] + [InlineData(nameof(Keyboard.Default), false)] + [InlineData(nameof(Keyboard.Email), false)] + [InlineData(nameof(Keyboard.Numeric), false)] + [InlineData(nameof(Keyboard.Plain), false)] + [InlineData(nameof(Keyboard.Telephone), true)] + [InlineData(nameof(Keyboard.Text), false)] + [InlineData(nameof(Keyboard.Url), false)] + public async Task ValidateTelephoneKeyboard(string keyboardName, bool expected) + { + var keyboard = (Keyboard)typeof(Keyboard).GetProperty(keyboardName).GetValue(null); + + var editor = new EditorStub() { Keyboard = keyboard }; + + await ValidatePropertyInitValue(editor, () => expected, GetNativeIsTelephoneKeyboard, expected); + } + + [Theory(DisplayName = "Validates Url Keyboard")] + [InlineData(nameof(Keyboard.Chat), false)] + [InlineData(nameof(Keyboard.Default), false)] + [InlineData(nameof(Keyboard.Email), false)] + [InlineData(nameof(Keyboard.Numeric), false)] + [InlineData(nameof(Keyboard.Plain), false)] + [InlineData(nameof(Keyboard.Telephone), false)] + [InlineData(nameof(Keyboard.Text), false)] + [InlineData(nameof(Keyboard.Url), true)] + public async Task ValidateUrlKeyboard(string keyboardName, bool expected) + { + var keyboard = (Keyboard)typeof(Keyboard).GetProperty(keyboardName).GetValue(null); + + var editor = new EditorStub() { Keyboard = keyboard }; + + await ValidatePropertyInitValue(editor, () => expected, GetNativeIsUrlKeyboard, expected); + } + + [Theory(DisplayName = "Validates Text Keyboard")] + [InlineData(nameof(Keyboard.Chat), false)] + [InlineData(nameof(Keyboard.Default), false)] + [InlineData(nameof(Keyboard.Email), false)] + [InlineData(nameof(Keyboard.Numeric), false)] + [InlineData(nameof(Keyboard.Plain), false)] + [InlineData(nameof(Keyboard.Telephone), false)] + [InlineData(nameof(Keyboard.Text), true)] + [InlineData(nameof(Keyboard.Url), false)] + public async Task ValidateTextKeyboard(string keyboardName, bool expected) + { + var keyboard = (Keyboard)typeof(Keyboard).GetProperty(keyboardName).GetValue(null); + + var editor = new EditorStub() { Keyboard = keyboard }; + + await ValidatePropertyInitValue(editor, () => expected, GetNativeIsTextKeyboard, expected); + } + + [Theory(DisplayName = "Validates Chat Keyboard")] + [InlineData(nameof(Keyboard.Chat), true)] + [InlineData(nameof(Keyboard.Default), false)] + [InlineData(nameof(Keyboard.Email), false)] + [InlineData(nameof(Keyboard.Numeric), false)] + [InlineData(nameof(Keyboard.Plain), false)] + [InlineData(nameof(Keyboard.Telephone), false)] + [InlineData(nameof(Keyboard.Text), false)] + [InlineData(nameof(Keyboard.Url), false)] + public async Task ValidateChatKeyboard(string keyboardName, bool expected) + { + var keyboard = (Keyboard)typeof(Keyboard).GetProperty(keyboardName).GetValue(null); + + var editor = new EditorStub() { Keyboard = keyboard }; + + await ValidatePropertyInitValue(editor, () => expected, GetNativeIsChatKeyboard, expected); + } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs index a8e4e56e019d..ebf3342dd946 100644 --- a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs @@ -87,5 +87,35 @@ bool GetNativeIsReadOnly(EditorHandler editorHandler) => bool GetNativeIsTextPredictionEnabled(EditorHandler editorHandler) => GetNativeEditor(editorHandler).AutocorrectionType == UITextAutocorrectionType.Yes; + + bool GetNativeIsNumericKeyboard(EditorHandler editorHandler) => + GetNativeEditor(editorHandler).KeyboardType == UIKeyboardType.DecimalPad; + + bool GetNativeIsEmailKeyboard(EditorHandler editorHandler) => + GetNativeEditor(editorHandler).KeyboardType == UIKeyboardType.EmailAddress; + + bool GetNativeIsTelephoneKeyboard(EditorHandler editorHandler) => + GetNativeEditor(editorHandler).KeyboardType == UIKeyboardType.PhonePad; + + bool GetNativeIsUrlKeyboard(EditorHandler editorHandler) => + GetNativeEditor(editorHandler).KeyboardType == UIKeyboardType.Url; + + bool GetNativeIsTextKeyboard(EditorHandler editorHandler) + { + var nativeEditor = GetNativeEditor(editorHandler); + + return nativeEditor.AutocapitalizationType == UITextAutocapitalizationType.Sentences && + nativeEditor.AutocorrectionType == UITextAutocorrectionType.Yes && + nativeEditor.SpellCheckingType == UITextSpellCheckingType.Yes; + } + + bool GetNativeIsChatKeyboard(EditorHandler editorHandler) + { + var nativeEditor = GetNativeEditor(editorHandler); + + return nativeEditor.AutocapitalizationType == UITextAutocapitalizationType.Sentences && + nativeEditor.AutocorrectionType == UITextAutocorrectionType.Yes && + nativeEditor.SpellCheckingType == UITextSpellCheckingType.No; + } } } \ No newline at end of file From f750eac016cf64e8a9a0cd3e6c17cd9e6cecf5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez=20Ruiz?= Date: Tue, 13 Apr 2021 14:29:21 +0200 Subject: [PATCH 2/4] Cleanup EditorHandler.Windows.cs --- src/Core/src/Handlers/Editor/EditorHandler.Windows.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs index 8ac1d31a0795..5054b4aa7638 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls; namespace Microsoft.Maui.Handlers { From b0e1c20343014365b21618a8aa6d5f1d329048a0 Mon Sep 17 00:00:00 2001 From: Rachel Kang Date: Thu, 27 May 2021 15:25:47 -0400 Subject: [PATCH 3/4] Add missing bracket --- src/Core/src/Handlers/Editor/EditorHandler.Android.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Android.cs b/src/Core/src/Handlers/Editor/EditorHandler.Android.cs index 5eea4b1cac8d..50fd26fbf0b6 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Android.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Android.cs @@ -109,6 +109,7 @@ public static void MapFont(EditorHandler handler, IEditor editor) public static void MapKeyboard(EditorHandler handler, IEditor editor) { handler.NativeView?.UpdateKeyboard(editor); + } void OnFocusedChange(bool hasFocus) { From 63b859cfa47ce59f64cef5e9bf1808c0e3d3a8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Sua=CC=81rez=20Ruiz?= Date: Mon, 31 May 2021 18:22:35 +0200 Subject: [PATCH 4/4] Fixed failing Editor handler tests --- .../src/Handlers/Editor/EditorHandler.iOS.cs | 4 ++-- src/Core/src/Platform/iOS/TextViewExtensions.cs | 17 ++++++----------- .../Handlers/Editor/EditorHandlerTests.cs | 7 ++++++- .../Handlers/Editor/EditorHandlerTests.iOS.cs | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs index d76a6eece168..c21cb012b90f 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs @@ -75,7 +75,7 @@ public static void MapIsReadOnly(EditorHandler handler, IEditor editor) public static void MapIsTextPredictionEnabled(EditorHandler handler, IEditor editor) { - handler.NativeView?.UpdatePredictiveText(editor); + handler.NativeView?.UpdateIsTextPredictionEnabled(editor); } public static void MapFormatting(EditorHandler handler, IEditor editor) @@ -93,7 +93,7 @@ public static void MapFont(EditorHandler handler, IEditor editor) handler.NativeView?.UpdateFont(editor, fontManager); } - void OnChanged(object? sender, System.EventArgs e) => OnTextChanged(); + void OnChanged(object? sender, EventArgs e) => OnTextChanged(); void OnTextChanged() { diff --git a/src/Core/src/Platform/iOS/TextViewExtensions.cs b/src/Core/src/Platform/iOS/TextViewExtensions.cs index e6da21bf4398..c99c33022a20 100644 --- a/src/Core/src/Platform/iOS/TextViewExtensions.cs +++ b/src/Core/src/Platform/iOS/TextViewExtensions.cs @@ -40,10 +40,12 @@ public static void UpdateMaxLength(this UITextView textView, IEditor editor) textView.AttributedText = newText; } - public static void UpdatePredictiveText(this UITextView textView, IEditor editor) + public static void UpdateIsTextPredictionEnabled(this UITextView textView, IEditor editor) { - textView.AutocorrectionType = editor.IsTextPredictionEnabled - ? UITextAutocorrectionType.Yes : UITextAutocorrectionType.No; + if (editor.IsTextPredictionEnabled) + textView.AutocorrectionType = UITextAutocorrectionType.Yes; + else + textView.AutocorrectionType = UITextAutocorrectionType.No; } public static void UpdateFont(this UITextView textView, ITextStyle textStyle, IFontManager fontManager) @@ -64,14 +66,7 @@ public static void UpdateKeyboard(this UITextView textView, IEditor editor) textView.ApplyKeyboard(keyboard); if (keyboard is not CustomKeyboard) - { - // TODO: IsSpellCheckEnabled handling must be here. - - if (!editor.IsTextPredictionEnabled) - { - textView.AutocorrectionType = UITextAutocorrectionType.No; - } - } + textView.UpdateIsTextPredictionEnabled(editor); textView.ReloadInputViews(); } diff --git a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs index 9406433a44fa..5162777f41f5 100644 --- a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs @@ -196,7 +196,12 @@ public async Task IsTextPredictionEnabledCorrectly(bool isEnabled) IsTextPredictionEnabled = isEnabled }; - await ValidatePropertyInitValue(editor, () => editor.IsTextPredictionEnabled, GetNativeIsTextPredictionEnabled, isEnabled); + var nativeIsTextPredictionEnabled = await GetValueAsync(editor, handler => + { + return GetNativeIsTextPredictionEnabled(handler); + }); + + Assert.Equal(isEnabled, nativeIsTextPredictionEnabled); } [Theory(DisplayName = "IsTextPredictionEnabled Updates Correctly")] diff --git a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs index 12f6411af463..61e73dd5cb31 100644 --- a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.iOS.cs @@ -63,7 +63,7 @@ public async Task FontFamilyInitializesCorrectly(string family) } MauiTextView GetNativeEditor(EditorHandler editorHandler) => - (MauiTextView)editorHandler.NativeView; + editorHandler.NativeView; string GetNativeText(EditorHandler editorHandler) => GetNativeEditor(editorHandler).Text;