Skip to content

Commit d53d4d5

Browse files
committed
Added a UITest
1 parent b017a77 commit d53d4d5

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue28121">
5+
<VerticalStackLayout>
6+
<Picker Focused="Picker_Focused"
7+
Unfocused="Picker_Unfocused"
8+
AutomationId="picker">
9+
<Picker.ItemsSource>
10+
<x:Array Type="{x:Type x:String}">
11+
<x:String>Item1</x:String>
12+
<x:String>Item2</x:String>
13+
<x:String>Item3</x:String>
14+
</x:Array>
15+
</Picker.ItemsSource>
16+
</Picker>
17+
<Label x:Name="FocusedLabel"
18+
AutomationId="focusedLabel"
19+
Text="Focused: false"/>
20+
<Label x:Name="UnfocusedLabel"
21+
AutomationId="unfocusedLabel"
22+
Text="Unfocused: false"/>
23+
</VerticalStackLayout>
24+
</ContentPage>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 28121, "Picker Focused/Unfocused Events Do Not Fire", PlatformAffected.Android)]
4+
5+
public partial class Issue28121 : ContentPage
6+
{
7+
public Issue28121()
8+
{
9+
InitializeComponent();
10+
}
11+
12+
void Picker_Focused(object sender, FocusEventArgs e)
13+
{
14+
FocusedLabel.Text = "Focused: true";
15+
}
16+
17+
void Picker_Unfocused(object sender, FocusEventArgs e)
18+
{
19+
UnfocusedLabel.Text = "Unfocused: true";
20+
}
21+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+

2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues
7+
{
8+
public class Issue28121 : _IssuesUITest
9+
{
10+
11+
public Issue28121(TestDevice testDevice) : base(testDevice)
12+
{
13+
}
14+
15+
public override string Issue => "Picker Focused/Unfocused Events Do Not Fire";
16+
17+
[Test]
18+
[Category(UITestCategories.Entry)]
19+
[Category(UITestCategories.Compatibility)]
20+
public void FocusAndUnfocusEventsShouldFire()
21+
{
22+
App.WaitForElement("picker");
23+
App.Tap("picker");
24+
App.WaitForElement("Item1");
25+
App.Click("Item1");
26+
var focusedLabelText = App.FindElement("focusedLabel").GetText();
27+
var unfocusedLabelText = App.FindElement("unfocusedLabel").GetText();
28+
29+
Assert.That(focusedLabelText, Is.EqualTo("Focused: true"));
30+
Assert.That(unfocusedLabelText, Is.EqualTo("Unfocused: true"));
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)