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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue18961.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue18961"
xmlns:local="clr-namespace:Maui.Controls.Sample">
<ContentPage.Resources>
<ResourceDictionary>

<Style TargetType="local:UITestEntry">
<Setter Property="IsCursorVisible" Value="False" />
<Setter Property="BackgroundColor" Value="LightGray" />
<Setter Property="Margin" Value="0, 12" />
</Style>

</ResourceDictionary>
</ContentPage.Resources>
<ScrollView
x:Name="TestScrollView"
AutomationId="TestScrollView">
<StackLayout
Padding="12">
<Label
AutomationId="WaitForStubControl"
Text="Modal Page margin correct after Keyboard opens"/>
<!--
Add enough entries into the stack layout so that we can
guarantee we'll have entries that would be covered by the keyboard
-->
<Button AutomationId="ScrollButton" Text="Scroll To End" Clicked="OnButtonClicked" />
<local:UITestEntry AutomationId="TestEntry1" Placeholder="First Entry" />
<local:UITestEntry AutomationId="TestEntry2" Placeholder="2" />
<local:UITestEntry AutomationId="TestEntry3" Placeholder="3" />
<local:UITestEntry AutomationId="TestEntry4" Placeholder="4" />
<local:UITestEntry AutomationId="TestEntry5" Placeholder="5" />
<local:UITestEntry AutomationId="TestEntry6" Placeholder="6" />
<local:UITestEntry AutomationId="TestEntry7" Placeholder="7" />
<local:UITestEntry AutomationId="TestEntry8" Placeholder="8" />
<local:UITestEntry AutomationId="TestEntry9" Placeholder="9" />
<local:UITestEntry AutomationId="TestEntry10" Placeholder="10" />
<local:UITestEntry AutomationId="TestEntry11" Placeholder="11" />
<local:UITestEntry AutomationId="TestEntry12" Placeholder="12" />
<local:UITestEntry AutomationId="TestEntry13" Placeholder="13" />
<local:UITestEntry AutomationId="TestEntry14" Placeholder="14" />
<local:UITestEntry AutomationId="TestEntry15" Placeholder="15" />
<local:UITestEntry AutomationId="TestEntry16" Placeholder="16" />
<local:UITestEntry AutomationId="TestEntry17" Placeholder="17" />
<local:UITestEntry AutomationId="TestEntry18" Placeholder="18" />
<local:UITestEntry AutomationId="TestEntry19" Placeholder="19" />
<local:UITestEntry AutomationId="TestEntry20" Placeholder="Last Entry" />
</StackLayout>
</ScrollView>
</ContentPage>
22 changes: 22 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue18961.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 18961, "Modal Page margin correct after Keyboard opens", PlatformAffected.Android)]
public partial class Issue18961 : ContentPage
{
public Issue18961()
{
InitializeComponent();
}

async void OnButtonClicked(object sender, EventArgs args)
{
var scrollY = TestScrollView.Height;
await TestScrollView.ScrollToAsync(0, scrollY, false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#if ANDROID
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue18961 : _IssuesUITest
{
const string ScrollButton = "ScrollButton";
const string LastEntry = "TestEntry20";

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

public override string Issue => "Modal Page margin correct after Keyboard opens";

[Test]
[Category(UITestCategories.Layout)]
public async Task ModalPageMarginCorrectAfterKeyboardOpens()
{
App.WaitForElement("WaitForStubControl");

// 1. Ensure that the keyboard is closed before we start.
App.DismissKeyboard();

// 2. Scroll to the end.
App.WaitForElement(ScrollButton);
App.Click(ScrollButton);
await Task.Delay(1000); // Wait for the scroll animation to finish.
App.ScrollDown("TestScrollView"); // Ensure that we are at the end of the scroll.

// 3. Focus latest Entry
App.WaitForElement(LastEntry);
App.EnterText(LastEntry, "test");
App.Click(LastEntry);
await Task.Delay(1000);

// 4. The keyboard has opened and the Entry have been translated above the keyboard.
App.Screenshot("The keyboard has opened and the Entry have been translated above the keyboard.");
VerifyScreenshot();

// 5. Close the keyboard to see if sizes adjust back.
App.DismissKeyboard();
await Task.Delay(1000);

// 6. Verify the latest Entry text.
var text = App.FindElement(LastEntry).GetText();
Assert.That(text, Is.EqualTo("test"));

// 7. Make sure that everything has returned to the initial size once the keyboard has closed.
App.Screenshot("Make sure that everything has returned to the initial size once the keyboard has closed.");
}
}
}
#endif
Loading