-
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.
[Android] SearchHandler - added focus/unfocus support
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.ManualTest, "24670", "SearchHandler.Focused event never fires", PlatformAffected.All)] | ||
public partial class Issue24670 : Shell | ||
{ | ||
public Issue24670() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void SearchHandler_Focused(object sender, EventArgs e) | ||
{ | ||
focusedLabel.Text = "Focused: True"; | ||
} | ||
|
||
private void SearchHandler_Unfocused(object sender, EventArgs e) | ||
{ | ||
unfocusedLabel.Text = "Unfocused: True"; | ||
} | ||
|
||
private void Button_Clicked(object sender, EventArgs e) | ||
{ | ||
searchHandler.SetIsFocused(!searchHandler.IsFocused); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Controls/tests/TestCases.HostApp/Issues/Issue24670.xaml
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,30 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue24670"> | ||
<ShellContent | ||
Title="Home" | ||
Route="MainPage"> | ||
<ContentPage> | ||
<Shell.SearchHandler> | ||
<SearchHandler | ||
SearchBoxVisibility="Expanded" | ||
Focused="SearchHandler_Focused" | ||
Unfocused="SearchHandler_Unfocused" | ||
Placeholder="Click to focus.."/> | ||
</Shell.SearchHandler> | ||
|
||
<StackLayout> | ||
<Button AutomationId="button" | ||
Clicked="Button_Clicked" | ||
Text="Click to focus/unfocus search handler"/> | ||
<Label x:Name="focusedLabel" | ||
AutomationId="focusedLabel" | ||
Text="Focused: False"/> | ||
<Label x:Name="unfocusedLabel" | ||
AutomationId="unfocusedLabel" | ||
Text="Unfocused: False"/> | ||
</StackLayout> | ||
</ContentPage> | ||
</ShellContent> | ||
</Shell> |
30 changes: 30 additions & 0 deletions
30
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24670.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,30 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue24670 : _IssuesUITest | ||
{ | ||
public override string Issue => "SearchHandler.Focused event never fires"; | ||
|
||
public Issue24670(TestDevice testDevice) : base(testDevice) | ||
{ | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.Shell)] | ||
[Category(UITestCategories.SearchBar)] | ||
public void SearchHandlerFocusAndUnfocusEventsShouldWork() | ||
{ | ||
App.Click("button"); | ||
App.Click("button"); | ||
|
||
var focusedLabelText = App.WaitForElement("focusedLabel").GetText(); | ||
var unfocusedLabelText = App.WaitForElement("unfocusedLabel").GetText(); | ||
|
||
Assert.That(focusedLabelText, Is.EqualTo("Focused: True")); | ||
Assert.That(unfocusedLabelText, Is.EqualTo("Unfocused: True")); | ||
} | ||
} | ||
} |