Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public SearchHandlerAppearanceTracker(UISearchBar searchBar, SearchHandler searc
_uiSearchBar.OnEditingStarted += OnEditingStarted;
_uiSearchBar.OnEditingStopped += OnEditingEnded;
_uiSearchBar.TextChanged += OnTextChanged;
_uiSearchBar.ShowsCancelButton = false;
GetDefaultSearchBarColors(_uiSearchBar);
var uiTextField = searchBar.FindDescendantView<UITextField>();
UpdateSearchBarColors();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22060.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 22060, "Flyout icon and content page title disappeared after focusing on the search handler", PlatformAffected.iOS)]
public class Issue22060Shell : Shell
{
public Issue22060Shell()
{
this.FlyoutBehavior = FlyoutBehavior.Flyout;

var shellContent = new ShellContent
{
Title = "Home",
Route = "MainPage",
Content = new Issue22060() { Title = "Home" }
};

Items.Add(shellContent);
}

class Issue22060 : ContentPage
{
public Issue22060()
{
Shell.SetSearchHandler(this, new SearchHandler
{
AutomationId = "searchHandler",
Placeholder = "SearchHandler",
});

this.SetBinding(TitleProperty, new Binding("Title", source: Shell.Current));
}
}
}
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
@@ -0,0 +1,26 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue22060 : _IssuesUITest
{
public override string Issue => "Flyout icon and content page title disappeared after focusing on the search handler";

public Issue22060(TestDevice device) : base(device)
{
}

[Test]
[Category(UITestCategories.Shell)]
[Category(UITestCategories.SearchBar)]
public void ShouldAppearFlyoutIconAndContentPageTitle()

Check failure on line 18 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs#L18

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs(18,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'ShouldAppearFlyoutIconAndContentPageTitle' has 2 `[Category]` attributes but should have exactly one

Check failure on line 18 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs#L18

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs(18,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'ShouldAppearFlyoutIconAndContentPageTitle' has 2 `[Category]` attributes but should have exactly one

Check failure on line 18 in src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs

View check run for this annotation

Azure Pipelines / maui-pr

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs#L18

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22060.cs(18,14): error MAUI0002: (NETCORE_ENGINEERING_TELEMETRY=Build) Test method 'ShouldAppearFlyoutIconAndContentPageTitle' has 2 `[Category]` attributes but should have exactly one
{
App.EnterTextInShellSearchHandler("Hello");
#if IOS // When the search handler is focused, the Cancel button is displayed on the right side of the search bar only on the iOS platform.
App.Tap("Cancel");
#endif
VerifyScreenshot();
}
}
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.
59 changes: 19 additions & 40 deletions src/TestUtils/src/UITest.Appium/HelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2736,55 +2736,34 @@ public static bool IsElementVisible(IApp app, string elementName)
}
}

/// <summary>
/// Gets the display density for the current device using the appropriate platform-specific method.
/// For Android, uses the Appium getDisplayDensity command for accurate results.
/// For iOS and Catalyst, uses the deviceScreenInfo command.
/// For other platforms, falls back to driver capabilities.
/// Enters text into the search handler element for the shell.
/// This method is used to enter the search handler element in the app.
/// It uses different queries based on the app type (Android, iOS, Catalyst, or Windows).
/// </summary>
/// <param name="app">The IApp instance representing the application.</param>
/// <returns>The display density as a double value (e.g., 1.0 for mdpi, 2.0 for xhdpi/Retina, 3.0 for xxhdpi/Retina HD)</returns>
public static double GetDisplayDensity(this IApp app)
{
if (app is not AppiumApp appiumApp)
{
throw new InvalidOperationException($"GetDisplayDensity is only supported on AppiumApp");
}

// Use platform-specific methods for accurate results
return app switch
{
AppiumAndroidApp androidApp => GetAndroidDisplayDensity(androidApp),
AppiumIOSApp iOSApp => GetIOSDisplayDensity(iOSApp),
_ => 1.0 // Fallback for other platforms (Catalyst, Windows)
};
}

static double GetAndroidDisplayDensity(AppiumAndroidApp androidApp)
/// <returns>The search handler element for the shell.</returns>
public static void EnterTextInShellSearchHandler(this IApp app, string text)
{
// Use the command executor to call the Android-specific action
float? response = (androidApp.Driver as AndroidDriver)?.GetDisplayDensity();
if (response is not null)
if (app is AppiumWindowsApp)
{
return (double)response.Value / 160f;
app.WaitForElement("TextBox");
app.EnterText("TextBox", text);
}

return 1.0;
}

static double GetIOSDisplayDensity(AppiumIOSApp iOSApp)
{
var response = (iOSApp.Driver as IOSDriver)?.ExecuteScript("mobile: deviceScreenInfo");
if (response is not null && response is IDictionary<string, object> screenInfo)
else if (app is AppiumIOSApp || app is AppiumCatalystApp || app is AppiumAndroidApp)
{
// Extract the scale factor from the deviceScreenInfo response
if (screenInfo.TryGetValue("scale", out var scaleValue))
IQuery query;
if (app is AppiumAndroidApp)
{
return Convert.ToDouble(scaleValue);
query = AppiumQuery.ByXPath("//android.widget.EditText");
}
else
{
query = AppiumQuery.ByXPath("//XCUIElementTypeSearchField");
}
}

return 1.0;
app.WaitForElement(query);
app.EnterText(query, text);
}
}
}
}
Loading