Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] moved FlyoutHeaderAdaptsToMinimumHeight to appium #24294

Merged
merged 3 commits into from
Aug 23, 2024
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 @@ -92,34 +92,7 @@ await RunShellTest(shell =>
Assert.Contains(shellSectionGrid, (shellSection as IVisualTreeElement).GetVisualChildren());
Assert.Contains(shellContentGrid, (shellContent as IVisualTreeElement).GetVisualChildren());
});
}

[Fact]
public async Task FlyoutHeaderAdaptsToMinimumHeight()
{
await RunShellTest(shell =>
{
var layout = new VerticalStackLayout()
{
new Label() { Text = "Flyout Header" }
};

layout.MinimumHeightRequest = 30;

shell.FlyoutHeader = layout;
shell.FlyoutHeaderBehavior = FlyoutHeaderBehavior.CollapseOnScroll;
},
async (shell, handler) =>
{
await OpenFlyout(handler);
var flyoutFrame = GetFrameRelativeToFlyout(handler, shell.FlyoutHeader as IView);

await AssertionExtensions.AssertEventually(() =>
{
return Math.Abs(30 - flyoutFrame.Height) < 0.2;
}, message: $"Expected: {30}. Actual: {flyoutFrame.Height}. Diff: {Math.Abs(30 - flyoutFrame.Height)}");
});
}
}

#if !WINDOWS
[Theory]
Expand Down
14 changes: 14 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24284.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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.Issue24284"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
<ShellContent Title="Page 1">
<ContentPage>
<Label HeightRequest="30" AutomationId="HeightReferenceLabel" Text="Hello, World!"/>
</ContentPage>
</ShellContent>
<ShellContent Title="Page 2">
<ContentPage/>
</ShellContent>
</Shell>
22 changes: 22 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24284.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 24284, "FlyoutHeaderAdaptsToMinimumHeight", PlatformAffected.All)]
public partial class Issue24284 : Shell
{
public Issue24284()
{
InitializeComponent();

var label = new Label()
{
AutomationId = "HeaderLabel",
Text = "Flyout Header",
MinimumHeightRequest = 30,
};

FlyoutHeader = label;
FlyoutHeaderBehavior = FlyoutHeaderBehavior.CollapseOnScroll;
FlyoutIsPresented = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue24284 : _IssuesUITest
{
public Issue24284(TestDevice testDevice) : base(testDevice){ }

public override string Issue => "FlyoutHeaderAdaptsToMinimumHeight";

[Test]
[Category(UITestCategories.Shell)]
public void FlyoutHeaderAdaptsToMinimumHeight()
{
var heightReferenceLabel = App.WaitForElement("HeightReferenceLabel").GetRect();
var headerLabel = App.WaitForElement("HeaderLabel").GetRect();

ClassicAssert.True(Math.Abs(headerLabel.Height - heightReferenceLabel.Height) < 0.2);
}
}
}
Loading