-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3110 from PrismLibrary/dev/ds/is-rootpage
Fixing IsRootPage
- Loading branch information
Showing
5 changed files
with
234 additions
and
89 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
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
104 changes: 104 additions & 0 deletions
104
tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Navigation/PrismWindowTests.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,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Prism.Controls; | ||
using Prism.DryIoc.Maui.Tests.Mocks.Views; | ||
|
||
namespace Prism.DryIoc.Maui.Tests.Fixtures.Navigation; | ||
|
||
public class PrismWindowTests : TestBase | ||
{ | ||
public PrismWindowTests(ITestOutputHelper testOutputHelper) | ||
: base(testOutputHelper) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void CurrentPageEqualsRootPage() | ||
{ | ||
var mauiApp = CreateBuilder(prism => prism.CreateWindow("MockViewA")) | ||
.Build(); | ||
var window = GetWindow(mauiApp); | ||
|
||
Assert.IsType<MockViewA>(window.CurrentPage); | ||
Assert.IsType<MockViewA>(window.Page); | ||
Assert.True(window.IsRootPage); | ||
} | ||
|
||
[Fact] | ||
public void CurrentPage_FromNavigationPage_EqualsRootPage() | ||
{ | ||
var mauiApp = CreateBuilder(prism => prism.CreateWindow("NavigationPage/MockViewA")) | ||
.Build(); | ||
var window = GetWindow(mauiApp); | ||
|
||
Assert.IsType<MockViewA>(window.CurrentPage); | ||
Assert.IsType<PrismNavigationPage>(window.Page); | ||
Assert.True(window.IsRootPage); | ||
} | ||
|
||
[Fact] | ||
public void CurrentPage_FromNavigationPage_IsNotRootPage() | ||
{ | ||
var mauiApp = CreateBuilder(prism => prism.CreateWindow("NavigationPage/MockViewA/MockViewB")) | ||
.Build(); | ||
var window = GetWindow(mauiApp); | ||
|
||
Assert.IsType<MockViewB>(window.CurrentPage); | ||
Assert.IsType<PrismNavigationPage>(window.Page); | ||
Assert.False(window.IsRootPage); | ||
} | ||
|
||
[Fact] | ||
public void CurrentPage_IsRoot_FromTabbedPage_WithNavigationPageTab() | ||
{ | ||
var mauiApp = CreateBuilder(prism => prism.CreateWindow(n => | ||
n.CreateBuilder() | ||
.AddTabbedSegment(b => b.CreateTab(t => t.AddNavigationPage().AddSegment("MockViewA")) | ||
.CreateTab("MockViewB")).NavigateAsync())) | ||
.Build(); | ||
var window = GetWindow(mauiApp); | ||
|
||
Assert.IsType<MockViewA>(window.CurrentPage); | ||
Assert.IsType<TabbedPage>(window.Page); | ||
Assert.True(window.IsRootPage); | ||
} | ||
|
||
[Fact] | ||
public void CurrentPage_IsNotRoot_FromTabbedPage_WithDeepLinkedNavigationPageTab() | ||
{ | ||
var mauiApp = CreateBuilder(prism => prism.CreateWindow(n => | ||
n.CreateBuilder() | ||
.AddTabbedSegment(b => b.CreateTab(t => | ||
t.AddNavigationPage() | ||
.AddSegment("MockViewA") | ||
.AddSegment("MockViewC")) | ||
.CreateTab("MockViewB")).NavigateAsync())) | ||
.Build(); | ||
var window = GetWindow(mauiApp); | ||
|
||
Assert.IsType<MockViewC>(window.CurrentPage); | ||
Assert.IsType<TabbedPage>(window.Page); | ||
Assert.False(window.IsRootPage); | ||
} | ||
|
||
[Fact] | ||
public void CurrentPage_IsRoot_WithFlyoutPage() | ||
{ | ||
var mauiApp = CreateBuilder(prism => prism.CreateWindow(n => | ||
n.CreateBuilder() | ||
.AddSegment("MockHome") | ||
.AddNavigationPage() | ||
.AddSegment("MockViewA") | ||
.NavigateAsync())) | ||
.Build(); | ||
|
||
var window = GetWindow(mauiApp); | ||
|
||
Assert.IsType<MockViewA>(window.CurrentPage); | ||
Assert.IsType<MockHome>(window.Page); | ||
Assert.True(window.IsRootPage); | ||
} | ||
} |
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
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