Skip to content

Commit

Permalink
test: Android full screen and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Sep 2, 2024
1 parent 5198fee commit d86d74c
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public async Task When_SimpleContentDialog(string dialogButton, int delayInSecon
else
{
ImageAssert.AreEqual(screenAfter, screenAfterDelay, tolerance: PixelTolerance.Exclusive(Constants.DefaultPixelTolerance));

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ public abstract class NavigationTestBase : TestBase
{
protected void InitTestSection(TestSections section)
{
// Mobile needs to be full screen to avoid screenshot asserting failures
// due to the status bar changes like network strength, time, etc
PlatformHelpers.On(
iOS: () => App.Tap("TestHarnessMainPageFullScreenButton"),
Android: () => App.Tap("TestHarnessMainPageFullScreenButton")
);

var theListView = App.MarkedAnywhere(TestHarness.Constants.TestSectionsListView);
App.WaitForElement(theListView);

theListView.SetDependencyPropertyValue("SelectedIndex", ((int)section).ToString());

App.WaitForElement(q => q.All().Marked(TestHarness.Constants.NavigationRoot));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public void When_PageNavigationRegisteredRoot()
App.WaitElement("OnePageToTwoPageButton");
var screenAfter = TakeScreenshot("When_PageNavigationXAML_After");
ImageAssert.AreEqual(screenBefore, screenAfter, tolerance: PixelTolerance.Exclusive(Constants.DefaultPixelTolerance));

}

[Test]
Expand All @@ -174,7 +173,6 @@ public void When_PageNavigationDataContextDidntChange()
InitTestSection(TestSections.Navigation_PageNavigation);

App.WaitThenTap("ShowOnePageButton");
App.WaitThenTap("OnePageGetUrlFromBrowser");

// If DataContext is ever changed to anything other than the expected
// the text will be "DataContext is not correct"
Expand Down
1 change: 1 addition & 0 deletions testing/TestHarness/TestHarness/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args)
}
_window.Activate();
}

#if USE_UITESTS
public static string GetDisplayScreenScaling(string value) => (DisplayInformation.GetForCurrentView().LogicalDpi * 100f / 96f).ToString(CultureInfo.InvariantCulture);
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Page
x:Class="TestHarness.Ext.Navigation.PageNavigation.PageNavigationFivePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestHarness.Ext.Navigation.PageNavigation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
<Page x:Class="TestHarness.Ext.Navigation.PageNavigation.PageNavigationFivePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestHarness.Ext.Navigation.PageNavigation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:uen="using:Uno.Extensions.Navigation.UI"
Expand All @@ -15,61 +14,109 @@
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<utu:NavigationBar Content="Page Navigation - Five"
AutomationProperties.AutomationId="PageNavigationFive" />
<utu:NavigationBar Content="Page Navigation - Five" AutomationProperties.AutomationId="PageNavigationFive" />
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center"
Grid.Row="1">
<TextBlock>
<Run Text="Created on UI Thread: " /><Run Text="{Binding CreatedOnUIThread}" />
<Run Text="Created on UI Thread: " /><Run Text="{Binding CreatedOnUIThread}" />
</TextBlock>
<Button AutomationProperties.AutomationId="FivePageBackButton"
Content="Back"
uen:Navigation.Request="-" />
<Button AutomationProperties.AutomationId="FivePageBackCodebehindButton"
Content="Back (Codebehind)"
Click="FivePageBackCodebehindClick" />
<Button AutomationProperties.AutomationId="FivePageBackViewModelButton"
Content="Back (ViewModel)"
Click="{x:Bind ViewModel.GoBack}" />
<Button AutomationProperties.AutomationId="FivePageToSixPageButton"
Content="Six"
uen:Navigation.Request="PageNavigationSix" />
<Button AutomationProperties.AutomationId="FivePageToSevenPageButton"
Content="Seven"
uen:Navigation.Request="PageNavigationSeven" />
<Button AutomationProperties.AutomationId="FivePageToEightPageButton"
Content="Eight"
uen:Navigation.Request="PageNavigationEight" />
<Button AutomationProperties.AutomationId="FivePageToNinePageButton"
Content="Nine"
uen:Navigation.Request="PageNavigationNine" />
<Button AutomationProperties.AutomationId="FivePageToTenPageButton"
Content="Ten"
uen:Navigation.Request="PageNavigationTen" />
<Button AutomationProperties.AutomationId="FivePageRootPageButton"
Content="/ (will navigate to Second (default) with One in backstack)"
uen:Navigation.Request="/" />
<Button AutomationProperties.AutomationId="FivePageRootOnePageButton"
Content="/One (will clear to One)"
uen:Navigation.Request="/PageNavigationOne" />
<Button AutomationProperties.AutomationId="FivePageRootThreePageButton"
Content="/Three (will navigate to Third with One and Two in backstack)"
uen:Navigation.Request="/PageNavigationThree" />
<Button AutomationProperties.AutomationId="FivePageRootOneFourPageButton"
Content="/One/Four (will navigate to Four with One in backstack)"
uen:Navigation.Request="/PageNavigationOne/PageNavigationFour" />
<Button AutomationProperties.AutomationId="FivePageRootThreeSevenClearPageButton"
Content="-/Three/Seven (will navigate to Seven with Six and Three in backstack)"
uen:Navigation.Request="-/PageNavigationThree/PageNavigationSeven" />

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!-- 8 Rows, as there are 16 buttons -->
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Button AutomationProperties.AutomationId="FivePageToSixPageViewModelWithDataButton"
Content="Six (ViewModel - With Data)"
Click="{x:Bind ViewModel.GoToSixWithData}" />
<Button AutomationProperties.AutomationId="FivePageToSixPageViewModelWithDataAndBackButton"
Content="Six (ViewModel - With Data and Back)"
Click="{x:Bind ViewModel.GoToSixWithDataAndBack}" />
<Button Grid.Row="0"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageBackButton"
Content="Back"
uen:Navigation.Request="-" />
<Button Grid.Row="0"
Grid.Column="1"
AutomationProperties.AutomationId="FivePageBackCodebehindButton"
Content="Back (Codebehind)"
Click="FivePageBackCodebehindClick" />
<Button Grid.Row="1"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageBackViewModelButton"
Content="Back (ViewModel)"
Click="{x:Bind ViewModel.GoBack}" />
<Button Grid.Row="1"
Grid.Column="1"
AutomationProperties.AutomationId="FivePageToSixPageButton"
Content="Six"
uen:Navigation.Request="PageNavigationSix" />
<Button Grid.Row="2"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageToSevenPageButton"
Content="Seven"
uen:Navigation.Request="PageNavigationSeven" />
<Button Grid.Row="2"
Grid.Column="1"
AutomationProperties.AutomationId="FivePageToEightPageButton"
Content="Eight"
uen:Navigation.Request="PageNavigationEight" />
<Button Grid.Row="3"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageToNinePageButton"
Content="Nine"
uen:Navigation.Request="PageNavigationNine" />
<Button Grid.Row="3"
Grid.Column="1"
AutomationProperties.AutomationId="FivePageToTenPageButton"
Content="Ten"
uen:Navigation.Request="PageNavigationTen" />
<Button Grid.Row="4"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageRootPageButton"
Content="/ (will navigate to Second (default) with One in backstack)"
uen:Navigation.Request="/" />
<Button Grid.Row="4"
Grid.Column="1"
AutomationProperties.AutomationId="FivePageRootOnePageButton"
Content="/One (will clear to One)"
uen:Navigation.Request="/PageNavigationOne" />
<Button Grid.Row="5"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageRootThreePageButton"
Content="/Three (will navigate to Third with One and Two in backstack)"
uen:Navigation.Request="/PageNavigationThree" />
<Button Grid.Row="5"
Grid.Column="1"
AutomationProperties.AutomationId="FivePageRootOneFourPageButton"
Content="/One/Four (will navigate to Four with One in backstack)"
uen:Navigation.Request="/PageNavigationOne/PageNavigationFour" />
<Button Grid.Row="6"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageRootThreeSevenClearPageButton"
Content="-/Three/Seven (will navigate to Seven with Six and Three in backstack)"
uen:Navigation.Request="-/PageNavigationThree/PageNavigationSeven" />


<Button Grid.Row="6"
Grid.Column="1"
AutomationProperties.AutomationId="FivePageToSixPageViewModelWithDataButton"
Content="Six (ViewModel - With Data)"
Click="{x:Bind ViewModel.GoToSixWithData}" />
<Button Grid.Row="7"
Grid.Column="0"
AutomationProperties.AutomationId="FivePageToSixPageViewModelWithDataAndBackButton"
Content="Six (ViewModel - With Data and Back)"
Click="{x:Bind ViewModel.GoToSixWithDataAndBack}" />
</Grid>
</StackPanel>
</Grid>
</Page>
29 changes: 23 additions & 6 deletions testing/TestHarness/TestHarness/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,29 @@
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock AutomationProperties.AutomationId="TestHarnessMainPageTitle"
Text="Test Harness"
Margin="20"
FontSize="30"
VerticalAlignment="Top"
HorizontalAlignment="Center" />

<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock AutomationProperties.AutomationId="TestHarnessMainPageTitle"
Text="Test Harness"
Margin="20"
FontSize="30"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Grid.Column="0" />

<Button AutomationProperties.AutomationId="TestHarnessMainPageFullScreenButton"
Click="Button_Click"
Style="{StaticResource IconButtonStyle}"
HorizontalAlignment="Right"
Grid.Column="1">
<PathIcon Data="M18 9H16V12H13V14H18V9ZM6 6H9V4H4V9H6V6ZM20 0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H20C21.1 18 22 17.1 22 16V2C22 0.9 21.1 0 20 0ZM20 16.01H2V1.99H20V16.01Z" Foreground="{ThemeResource PrimaryBrush}" />
</Button>
</Grid>

<ListView SelectionChanged="TestSectionSelectionChanged"
SelectionMode="Single"
Expand Down
15 changes: 15 additions & 0 deletions testing/TestHarness/TestHarness/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

using Microsoft.UI.Windowing;

namespace TestHarness;

public sealed partial class MainPage : Page
{
private bool _isFullScreen = false;

public MainPage()
{
this.InitializeComponent();
Expand Down Expand Up @@ -40,6 +44,17 @@ private void TestSectionSelectionChanged(object sender, SelectionChangedEventArg
this.Frame.Navigate(section.MainPage, hostInit);
}
}

private void Button_Click(object sender, RoutedEventArgs e)
{
var app = Application.Current as App;

var presenterKind = _isFullScreen ? AppWindowPresenterKind.Default : AppWindowPresenterKind.FullScreen;

_isFullScreen = !_isFullScreen;

app.Window.AppWindow.SetPresenter(presenterKind);
}
}


0 comments on commit d86d74c

Please sign in to comment.