-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Ensure duplicated navigation wont happen
- Loading branch information
1 parent
ae9c07f
commit 5d63323
Showing
12 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
testing/TestHarness/TestHarness.UITest/Ext/Navigation/AddressBar/Given_AddressBar.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace TestHarness.UITest; | ||
|
||
public class Given_AddressBar : NavigationTestBase | ||
{ | ||
[Test] | ||
public async Task When_AddressBar_HomePage_Wont_Navigate_Twice() | ||
{ | ||
InitTestSection(TestSections.Navigation_AddressBar); | ||
|
||
App.WaitElement("TbInstanceCountProperty"); | ||
|
||
var intanceCount = App.GetText("TbInstanceCountProperty"); | ||
|
||
Assert.AreEqual("1", intanceCount); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/AddressBarHomeModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace TestHarness.Ext.Navigation.AddressBar; | ||
|
||
public partial class AddressBarHomeModel | ||
{ | ||
public static int InstanceCount | ||
{ | ||
get => ApplicationData.Current.LocalSettings.Values.TryGetValue(Constants.HomeInstanceCountKey, out var value) | ||
? (int)value | ||
: 0; | ||
private set => ApplicationData.Current.LocalSettings.Values[Constants.HomeInstanceCountKey] = value; | ||
} | ||
|
||
public int InstanceCountProperty { get; private set; } | ||
|
||
public AddressBarHomeModel() | ||
{ | ||
InstanceCountProperty = ++InstanceCount; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/AddressBarHomePage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Page x:Class="TestHarness.Ext.Navigation.AddressBar.AddressBarHomePage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:TestHarness.Ext.Navigation.RoutesNavigation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:uen="using:Uno.Extensions.Navigation.UI" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400"> | ||
|
||
<Grid> | ||
<StackPanel Grid.Row="1" | ||
HorizontalAlignment="Center" | ||
Spacing="16"> | ||
<TextBlock Text="AddressBar HomePage" /> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="This page was created: " /> | ||
<TextBlock AutomationProperties.AutomationId="TbInstanceCountProperty" | ||
Text="{Binding InstanceCountProperty, Mode=TwoWay}" /> | ||
<TextBlock Text=" times" /> | ||
</StackPanel> | ||
|
||
</StackPanel> | ||
|
||
</Grid> | ||
</Page> |
9 changes: 9 additions & 0 deletions
9
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/AddressBarHomePage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace TestHarness.Ext.Navigation.AddressBar; | ||
|
||
public sealed partial class AddressBarHomePage : Page | ||
{ | ||
public AddressBarHomePage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/AddressBarHostInit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace TestHarness.Ext.Navigation.AddressBar; | ||
|
||
public class AddressBarHostInit : BaseHostInitialization | ||
{ | ||
protected override string[] ConfigurationFiles => new string[] { "TestHarness.Ext.Navigation.AddressBar.appsettings.addressbar.json" }; | ||
|
||
public AddressBarHostInit() | ||
{ | ||
if (ApplicationData.Current.LocalSettings.Values.TryGetValue(Constants.HomeInstanceCountKey, out var value)) | ||
{ | ||
ApplicationData.Current.LocalSettings.Values[Constants.HomeInstanceCountKey] = 0; | ||
} | ||
} | ||
protected override void RegisterRoutes(IViewRegistry views, IRouteRegistry routes) | ||
{ | ||
views.Register( | ||
new ViewMap<AddressBarHomePage, AddressBarHomeModel>(), | ||
new ViewMap(ViewModel: typeof(ShellViewModel)) | ||
); | ||
|
||
routes.Register( | ||
new RouteMap("", View: views.FindByViewModel<ShellViewModel>(), | ||
Nested: | ||
[ | ||
new RouteMap("AddressBarHome", View: views.FindByViewModel<AddressBarHomeModel>(), IsDefault: true) | ||
] | ||
) | ||
); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/AddressBarMainPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<testharness:BaseTestSectionPage xmlns:testharness="using:TestHarness" | ||
x:Class="TestHarness.Ext.Navigation.AddressBar.AddressBarMainPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:TestHarness.Ext.Navigation.RoutesNavigation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
xmlns:uen="using:Uno.Extensions.Navigation.UI" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<TextBlock Text="AddressBar Navigation Tests" | ||
Margin="20" | ||
FontSize="30" /> | ||
|
||
<ContentControl AutomationProperties.AutomationId="NavigationRoot" | ||
x:Name="NavigationRoot" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
HorizontalContentAlignment="Stretch" | ||
VerticalContentAlignment="Stretch" | ||
Grid.Row="1" /> | ||
|
||
<StackPanel Grid.Row="2" | ||
Orientation="Horizontal" | ||
HorizontalAlignment="Center"> | ||
<Button AutomationProperties.AutomationId="ShowAppButton" | ||
Content="AddressBar App" | ||
Click="ShowAppClick" /> | ||
</StackPanel> | ||
</Grid> | ||
|
||
</testharness:BaseTestSectionPage> |
15 changes: 15 additions & 0 deletions
15
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/AddressBarMainPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace TestHarness.Ext.Navigation.AddressBar; | ||
|
||
[TestSectionRoot("AddressBar Navigation", TestSections.Navigation_AddressBar, typeof(AddressBarHostInit))] | ||
public sealed partial class AddressBarMainPage : BaseTestSectionPage | ||
{ | ||
public AddressBarMainPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
public async void ShowAppClick(object sender, RoutedEventArgs e) | ||
{ | ||
await Navigator.NavigateRouteAsync(this, ""); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/Constants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace TestHarness.Ext.Navigation.AddressBar; | ||
|
||
internal class Constants | ||
{ | ||
public const string HomeInstanceCountKey = "HomeInstanceCount"; | ||
} |
11 changes: 11 additions & 0 deletions
11
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/ShellViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace TestHarness.Ext.Navigation.AddressBar; | ||
|
||
public record ShellViewModel | ||
{ | ||
public INavigator? Navigator { get; init; } | ||
|
||
public ShellViewModel(INavigator navigator) | ||
{ | ||
Navigator = navigator; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
testing/TestHarness/TestHarness/Ext/Navigation/AddressBar/appsettings.addressbar.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"HostConfiguration": { | ||
"LaunchUrl": "http://localhost:5000/AddressBarHome" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters