test: Add url test for page navigation
(cherry picked from commit de9db874fe
)
This commit is contained in:
Родитель
555ddb401a
Коммит
f9df35e8b7
|
@ -1,14 +1,14 @@
|
|||
<Page x:Class="TestHarness.Ext.Navigation.PageNavigation.PageNavigationOnePage"
|
||||
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:local="using:TestHarness.Ext.Navigation.PageNavigation"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:uen="using:Uno.Extensions.Navigation.UI"
|
||||
xmlns:utu="using:Uno.Toolkit.UI"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -16,60 +16,61 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<utu:NavigationBar Content="Page Navigation - One"
|
||||
AutomationProperties.AutomationId="PageNavigationOne" />
|
||||
<StackPanel HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Grid.Row="1">
|
||||
<utu:NavigationBar AutomationProperties.AutomationId="PageNavigationOne" Content="Page Navigation - One" />
|
||||
<StackPanel Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock>
|
||||
<Run Text="Created on UI Thread: " /><Run Text="{Binding CreatedOnUIThread}" />
|
||||
</TextBlock>
|
||||
<Button AutomationProperties.AutomationId="OnePageToTwoPageButton"
|
||||
Content="Two"
|
||||
uen:Navigation.Request="PageNavigationTwo" />
|
||||
<Button uen:Navigation.Request="PageNavigationTwo"
|
||||
AutomationProperties.AutomationId="OnePageToTwoPageButton"
|
||||
Content="Two" />
|
||||
<Button AutomationProperties.AutomationId="OnePageToTwoPageCodebehindButton"
|
||||
Content="Two (Codebehind)"
|
||||
Click="OnePageToTwoPageCodebehindClick" />
|
||||
Click="OnePageToTwoPageCodebehindClick"
|
||||
Content="Two (Codebehind)" />
|
||||
<Button AutomationProperties.AutomationId="OnePageToTwoPageViewModelButton"
|
||||
Content="Two (ViewModel)"
|
||||
Click="{x:Bind ViewModel.GoToTwo}" />
|
||||
Click="{x:Bind ViewModel.GoToTwo}"
|
||||
Content="Two (ViewModel)" />
|
||||
<Button AutomationProperties.AutomationId="RapidSettingsWriteTestButton"
|
||||
Content="Settings Write Test"
|
||||
Click="{x:Bind ViewModel.SettingsWriteTest}" />
|
||||
Click="{x:Bind ViewModel.SettingsWriteTest}"
|
||||
Content="Settings Write Test" />
|
||||
<TextBlock x:Name="TxtUrl" AutomationProperties.AutomationId="OnePageTxtUrlFromBrowser" />
|
||||
<Button AutomationProperties.AutomationId="OnePageGetUrlFromBrowser"
|
||||
Click="GetUrlFromBrowser"
|
||||
Content="Get URL" />
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="2">
|
||||
<muxc:ItemsRepeater ItemsSource="{Binding Items}"
|
||||
uen:Navigation.Request="PageNavigationTwo">
|
||||
<muxc:ItemsRepeater uen:Navigation.Request="PageNavigationTwo" ItemsSource="{Binding Items}">
|
||||
<muxc:ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<!--<UserControl>-->
|
||||
<Grid Height="200"
|
||||
Background="Red">
|
||||
<Border Background="Pink"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Center">
|
||||
<TextBlock Text="{Binding}" />
|
||||
</Border>
|
||||
<utu:CardContentControl Height="50"
|
||||
Width="200"
|
||||
Style="{StaticResource FilledCardContentControlStyle}"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch">
|
||||
<utu:CardContentControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<Border Background="Green"
|
||||
<Grid Height="200" Background="Red">
|
||||
<Border HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
Background="Pink">
|
||||
<TextBlock Text="{Binding}" />
|
||||
</Border>
|
||||
<utu:CardContentControl Width="200"
|
||||
Height="50"
|
||||
Width="200">
|
||||
<TextBlock Text="Inner card" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</utu:CardContentControl.ContentTemplate>
|
||||
</utu:CardContentControl>
|
||||
<Button VerticalAlignment="Bottom"
|
||||
Content="Go to Three"
|
||||
uen:Navigation.Request="PageNavigationThree" />
|
||||
</Grid>
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
Style="{StaticResource FilledCardContentControlStyle}">
|
||||
<utu:CardContentControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<Border Width="200"
|
||||
Height="50"
|
||||
Background="Green">
|
||||
<TextBlock Text="Inner card" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</utu:CardContentControl.ContentTemplate>
|
||||
</utu:CardContentControl>
|
||||
<Button VerticalAlignment="Bottom"
|
||||
uen:Navigation.Request="PageNavigationThree"
|
||||
Content="Go to Three" />
|
||||
</Grid>
|
||||
<!--</UserControl>-->
|
||||
</DataTemplate>
|
||||
</muxc:ItemsRepeater.ItemTemplate>
|
||||
|
|
|
@ -14,4 +14,22 @@ public sealed partial class PageNavigationOnePage : Page
|
|||
await this.Navigator()!.NavigateViewAsync<PageNavigationTwoPage>(this);
|
||||
}
|
||||
|
||||
|
||||
public async void GetUrlFromBrowser(object sender, RoutedEventArgs e)
|
||||
{
|
||||
#if __WASM__
|
||||
var url = Imports.GetLocation();
|
||||
|
||||
TxtUrl.Text = url;
|
||||
#else
|
||||
TxtUrl.Text = "Not supported";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if __WASM__
|
||||
internal static partial class Imports
|
||||
{
|
||||
[System.Runtime.InteropServices.JavaScript.JSImport("globalThis.Uno.Extensions.Hosting.getLocation")]
|
||||
public static partial string GetLocation();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<ProjectGuid>6279c845-92f8-4333-ab99-3d213163593c</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
|
@ -37,4 +40,4 @@
|
|||
<_Globbled_Page Remove="Ext\Navigation\NavigationView\NavigationViewDataRecipeDetailsPage.xaml" />
|
||||
<_Globbled_Page Remove="Ext\Navigation\NavigationView\NavigationViewDataRecipesPage.xaml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -176,4 +176,27 @@ public class Given_PageNavigation : NavigationTestBase
|
|||
App.WaitThenTap("FourPageToFivePageButton");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ActivePlatforms(Platform.Browser)]
|
||||
public void When_PageNavigationNavigateRootUpdateUrl()
|
||||
{
|
||||
InitTestSection(TestSections.Navigation_PageNavigation);
|
||||
|
||||
App.WaitThenTap("ShowOnePageButton");
|
||||
|
||||
App.WaitThenTap("OnePageGetUrlFromBrowser");
|
||||
App.WaitElement("OnePageTxtUrlFromBrowser");
|
||||
var urlBefore = App.GetText("OnePageTxtUrlFromBrowser");
|
||||
|
||||
App.WaitThenTap("OnePageToTwoPageButton");
|
||||
|
||||
App.WaitThenTap("TwoPageBackButton");
|
||||
|
||||
App.WaitThenTap("OnePageGetUrlFromBrowser");
|
||||
App.WaitElement("OnePageTxtUrlFromBrowser");
|
||||
var urlAfter = App.GetText("OnePageTxtUrlFromBrowser");
|
||||
|
||||
Assert.AreEqual(urlBefore, urlAfter);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче