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

fix: Solve PaddingMask.Top with StatusBarTranslucent #9021

Closed
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
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using SamplesApp.UITests.TestFramework;
using Uno.UITest.Helpers;
using Uno.UITest.Helpers.Queries;

namespace SamplesApp.UITests.Windows_UI_Xaml.WindowTests
{
[TestFixture]
public partial class WindowTests : SampleControlUITestBase
{
[Test]
[AutoRetry]
[ActivePlatforms(Platform.Android)] // Tests display of Android native view
public void When_StatusBarTranslucent_PaddingTop()
{
Run("UITests.Windows_UI_Xaml.WindowTests.Window_PaddingTop_SBT");

var blockSBT = _app.Marked("blockSBT");
_app.WaitForElement(blockSBT);

var screenRectBefore = _app.GetRect("blockSBT");

var screenRectBeforex = screenRectBefore.X;
var screenRectBeforey = screenRectBefore.Y;

//Only to developer see the position of screenRectBefore
var before = TakeScreenshot("Before");

_app.FastTap("boxSBT");

//Wait Show KeyBoard after TextBox Click
_app.Wait(TimeSpan.FromMilliseconds(500));

var screenRectAfter = _app.GetRect("blockSBT");

var screenRectAfterx = screenRectAfter.X;
var screenRectAftery = screenRectAfter.Y;

//Only to developer see the position of screenRectAfter
var after = TakeScreenshot("After");

Assert.AreEqual((screenRectBeforex, screenRectBeforey), (screenRectAfterx, screenRectAftery));

}
}
}
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\WindowTests\Window_PaddingTop_SBT.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\XamlRoot\XamlRoot_Properties.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -5325,6 +5329,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\WindowTests\Window_ContentIsFullyVisible.xaml.cs">
<DependentUpon>Window_ContentIsFullyVisible.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\WindowTests\Window_PaddingTop_SBT.xaml.cs">
<DependentUpon>Window_PaddingTop_SBT.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\XamlRoot\XamlRoot_Properties.xaml.cs">
<DependentUpon>XamlRoot_Properties.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--Test for [Android] VisibleBoundsPadding.PaddingMask.Top does not always work as intended #6218
and
[Android] When keyboard with InputScope=CurrencyAmount is displayed, it can break the status bar. #6216-->
<!--Window_PaddingTop_StatusBarTranslucent-->
<UserControl
x:Class="UITests.Windows_UI_Xaml.WindowTests.Window_PaddingTop_SBT"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Xaml.WindowTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:toolkit="using:Uno.UI.Toolkit"
d:DesignHeight="300"
d:DesignWidth="400">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<Grid Background="Red"
toolkit:VisibleBoundsPadding.PaddingMask="All">

<TextBox x:Name="boxSBT" InputScope="CurrencyAmount"
Grid.Row="0" />

<TextBlock x:Name="blockSBT" Text="Expected result ALL"
VerticalAlignment="Top" />

<TextBlock Text="Expected result ALL"
VerticalAlignment="Bottom" />
</Grid>

<Grid Background="Green"
Grid.Column="1"
toolkit:VisibleBoundsPadding.PaddingMask="Top">

<TextBox InputScope="CurrencyAmount"
Grid.Row="0" />

<TextBlock Text="Actual result TOP"
VerticalAlignment="Top" />
<TextBlock Text="Actual result TOP"
VerticalAlignment="Bottom" />
</Grid>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;

using Uno.UI.Samples.Controls;

using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics.Display;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace UITests.Windows_UI_Xaml.WindowTests
{
public sealed partial class Window_PaddingTop_SBT : UserControl
{
public Window_PaddingTop_SBT()
{
this.InitializeComponent();
}
}
}
3 changes: 2 additions & 1 deletion src/Uno.UI/UI/Xaml/Window.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ public bool IsStatusBarTranslucent()
}

return activity.Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentStatus)
|| activity.Window.Attributes.Flags.HasFlag(WindowManagerFlags.LayoutNoLimits);
|| activity.Window.Attributes.Flags.HasFlag(WindowManagerFlags.LayoutNoLimits)
|| activity.Window.Attributes.Flags.HasFlag(WindowManagerFlags.DrawsSystemBarBackgrounds);
}
#endregion

Expand Down