Skip to content

Commit 756a5f5

Browse files
CopilotNirmalKumarYuvaraj
authored andcommitted
Add test for AdjustPan mode to ensure no insets are applied
- Created Issue32041AdjustPan.xaml and code-behind for AdjustPan test - Added VerifyAdjustPanDoesNotApplyInsets test to ensure no regression - Verifies that with AdjustPan mode, no keyboard insets are applied Co-authored-by: NirmalKumarYuvaraj <[email protected]>
1 parent 3d76cb5 commit 756a5f5

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.Issue32041AdjustPan"
5+
Title="Issue 32041 AdjustPan">
6+
<VerticalStackLayout Padding="10" Spacing="10">
7+
<Label
8+
Text="Test keyboard with SoftInput.AdjustPan"
9+
FontSize="18"
10+
FontAttributes="Bold"
11+
Margin="0,10,0,20"/>
12+
13+
<Label
14+
Text="Instructions: With AdjustPan mode, the window is panned (moved) instead of resized. The entry should not receive insets."
15+
FontSize="14"
16+
Margin="0,0,0,10"/>
17+
18+
<Border
19+
AutomationId="ContentBorderPan"
20+
Stroke="Green"
21+
StrokeThickness="2"
22+
BackgroundColor="LightYellow"
23+
Padding="10"
24+
VerticalOptions="End">
25+
<VerticalStackLayout Spacing="10">
26+
<Label
27+
Text="Sample content for AdjustPan test"
28+
AutomationId="SampleLabelPan"
29+
FontSize="14"/>
30+
31+
<Label
32+
Text="With AdjustPan, the entire window shifts up when the keyboard appears, but no insets are applied to the content."
33+
AutomationId="FillerLabelPan"
34+
FontSize="12"
35+
TextColor="DarkGreen"/>
36+
37+
<Entry
38+
Placeholder="Type here - window should pan, no insets applied"
39+
AutomationId="TestEntryPan"
40+
VerticalOptions="End"/>
41+
</VerticalStackLayout>
42+
</Border>
43+
</VerticalStackLayout>
44+
</ContentPage>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Android.Views;
2+
3+
namespace Maui.Controls.Sample.Issues;
4+
5+
[Issue(IssueTracker.Github, 32041, "Verify AdjustPan mode does not apply keyboard insets", PlatformAffected.Android, issueTestNumber: 2)]
6+
public partial class Issue32041AdjustPan : ContentPage
7+
{
8+
public Issue32041AdjustPan()
9+
{
10+
InitializeComponent();
11+
12+
#if ANDROID
13+
// Set SoftInput.AdjustPan - this should NOT apply insets
14+
// The window should pan instead
15+
var window = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity?.Window;
16+
window?.SetSoftInputMode(SoftInput.AdjustPan | SoftInput.StateUnspecified);
17+
#endif
18+
}
19+
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32041.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,38 @@ public void VerifyKeyboardDoesNotOverlapEntryWithAdjustResize()
4444
$"Entry bottom ({entryBottom}) should be visible on screen (height: {screenHeight})");
4545
}
4646
}
47+
48+
public class Issue32041AdjustPan : _IssuesUITest
49+
{
50+
public override string Issue => "Verify AdjustPan mode does not apply keyboard insets";
51+
52+
public Issue32041AdjustPan(TestDevice device) : base(device)
53+
{
54+
}
55+
56+
[Test]
57+
[Category(UITestCategories.SafeAreaEdges)]
58+
public void VerifyAdjustPanDoesNotApplyInsets()
59+
{
60+
// Wait for the entry to be visible
61+
App.WaitForElement("TestEntryPan");
62+
63+
// Get the border's initial padding before keyboard appears
64+
var borderBefore = App.FindElement("ContentBorderPan").GetRect();
65+
66+
// Tap the entry to show the keyboard
67+
App.Tap("TestEntryPan");
68+
69+
// Wait a moment for keyboard to appear
70+
App.WaitForElement("TestEntryPan");
71+
72+
// Get the border's padding after keyboard appears
73+
var borderAfter = App.FindElement("ContentBorderPan").GetRect();
74+
75+
// With AdjustPan, the border should NOT have changed size
76+
// (no insets should be applied, the window just pans)
77+
Assert.That(borderAfter.Height, Is.EqualTo(borderBefore.Height).Within(5),
78+
$"Border height should not change with AdjustPan (no insets applied). Before: {borderBefore.Height}, After: {borderAfter.Height}");
79+
}
80+
}
4781
#endif

0 commit comments

Comments
 (0)