-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move keyboard device tests to appium (#20670)
- Loading branch information
Showing
4 changed files
with
173 additions
and
89 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/Controls/samples/Controls.Sample.UITests/Issues/Issue5724.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System.Threading; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Platform; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 5724, "Next Moves To Next Entry and Done Closes Input View", PlatformAffected.Android)] | ||
public class Issue5724 : TestContentPage | ||
{ | ||
protected override void Init() | ||
{ | ||
var layout = new VerticalStackLayout(); | ||
|
||
var entry1 = new Entry | ||
{ | ||
Text = "Entry 1", | ||
ReturnType = ReturnType.Next, | ||
AutomationId = "Entry1" | ||
}; | ||
|
||
entry1.Focused += async (_, _) => | ||
{ | ||
// Make sure keyboard opens | ||
await entry1.ShowSoftInputAsync(CancellationToken.None); | ||
}; | ||
|
||
var entry2 = new Entry | ||
{ | ||
Text = "Entry 2", | ||
ReturnType = ReturnType.Next, | ||
AutomationId = "Entry2" | ||
}; | ||
|
||
layout.Add(entry1); | ||
layout.Add(entry2); | ||
|
||
var entry3 = new Entry() | ||
{ | ||
Text = "Entry Done", | ||
ReturnType = ReturnType.Done, | ||
AutomationId = "EntryDone" | ||
}; | ||
|
||
entry3.Focused += async (_, _) => | ||
{ | ||
// Make sure keyboard opens | ||
await entry3.ShowSoftInputAsync(CancellationToken.None); | ||
}; | ||
|
||
layout.Add(entry3); | ||
|
||
layout.Add(new Entry() | ||
{ | ||
Text = "Entry Done", | ||
ReturnType = ReturnType.Done, | ||
AutomationId = "EntryDone2" | ||
}); | ||
|
||
layout.Add(new Button() | ||
{ | ||
Text = "Send Next Button", | ||
AutomationId = "SendNext", | ||
Command = new Command(() => | ||
{ | ||
#if ANDROID | ||
Handler.MauiContext.Context | ||
.GetActivity() | ||
.CurrentFocus | ||
?.OnCreateInputConnection(new Android.Views.InputMethods.EditorInfo()) | ||
?.PerformEditorAction(Android.Views.InputMethods.ImeAction.Next); | ||
#endif | ||
}) | ||
}); | ||
|
||
layout.Add(new Button() | ||
{ | ||
Text = "Send Done Button", | ||
AutomationId = "SendDone", | ||
Command = new Command(() => | ||
{ | ||
#if ANDROID | ||
Handler.MauiContext.Context | ||
.GetActivity() | ||
.CurrentFocus | ||
?.OnCreateInputConnection(new Android.Views.InputMethods.EditorInfo()) | ||
?.PerformEditorAction(Android.Views.InputMethods.ImeAction.Done); | ||
#endif | ||
}) | ||
}); | ||
|
||
Content = layout; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium.Appium.Android; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue5724 : _IssuesUITest | ||
{ | ||
public Issue5724(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "Next Moves To Next Entry and Done Closes Input View"; | ||
|
||
[Test] | ||
public async Task TappingNextMovesToNextElement() | ||
{ | ||
this.IgnoreIfPlatforms(new[] | ||
{ | ||
TestDevice.Mac, | ||
TestDevice.iOS, | ||
TestDevice.Windows, | ||
}, "Send Keys only works on Android which is why we are ignoring these other platforms"); | ||
|
||
App.WaitForElement("Entry1"); | ||
App.Click("Entry1"); | ||
|
||
await Task.Yield(); | ||
|
||
App.Click("SendNext"); | ||
await Task.Yield(); | ||
|
||
Assert.True(App.IsFocused("Entry2")); | ||
} | ||
|
||
[Test] | ||
public async Task TappingDoneClosesKeyboard() | ||
{ | ||
this.IgnoreIfPlatforms(new[] | ||
{ | ||
TestDevice.Mac, | ||
TestDevice.iOS, | ||
TestDevice.Windows, | ||
}, "Send Keys only works on Android which is why we are ignoring these other platforms"); | ||
|
||
App.WaitForElement("EntryDone"); | ||
App.Click("EntryDone"); | ||
|
||
await Task.Yield(); | ||
Assert.True(App.IsKeyboardShown()); | ||
App.Click("SendDone"); | ||
await Task.Yield(); | ||
Assert.False(App.IsKeyboardShown()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters