Skip to content
Merged
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
25 changes: 25 additions & 0 deletions src/Controls/src/Core/Window/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,31 @@ public NavigationImpl(Window owner)
_owner = owner;
}

protected override void OnInsertPageBefore(Page page, Page before)
{
throw new InvalidOperationException("InsertPageBefore is not supported, please use a NavigationPage.");
}

protected override Task OnPushAsync(Page page, bool animated)
{
throw new InvalidOperationException("PushAsync is not supported, please use a NavigationPage.");
}

protected override Task<Page> OnPopAsync(bool animated)
{
throw new InvalidOperationException("PopAsync is not supported, please use a NavigationPage.");
}

protected override Task OnPopToRootAsync(bool animated)
{
throw new InvalidOperationException("PopToRootAsync is not supported, please use a NavigationPage.");
}

protected override void OnRemovePage(Page page)
{
throw new InvalidOperationException("RemovePage is not supported, please use a NavigationPage.");
}

protected override IReadOnlyList<Page> GetModalStack()
{
return _owner.ModalNavigationManager.ModalStack;
Expand Down
23 changes: 23 additions & 0 deletions src/Controls/tests/Core.UnitTests/NavigationUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,29 @@ public async Task PopModalWithEmptyStackThrows()
Assert.ThrowsAsync<InvalidOperationException>(() => window.Navigation.PopModalAsync());
}

[Fact]
public async Task InvalidOperationExceptionIsThrownWhenNavigatingOutsideNavigationPage()
{
var window = new TestWindow(new ContentPage());
var contentPage1 = new ContentPage();
var contentPage2 = new ContentPage();

Assert.ThrowsAsync<InvalidOperationException>(() => window.Navigation.PushAsync(contentPage1));
Comment thread
jfversluis marked this conversation as resolved.
Assert.ThrowsAsync<InvalidOperationException>(() => window.Navigation.PopAsync());
Assert.ThrowsAsync<InvalidOperationException>(() => window.Navigation.PopToRootAsync());
Assert.Throws<InvalidOperationException>(() => window.Navigation.InsertPageBefore(contentPage1, contentPage2));
Assert.Throws<InvalidOperationException>(() => window.Navigation.RemovePage(contentPage1));
}

[Fact]
public async Task RemoveWrappingIntoNavigationPage()
{
var window = new TestWindow(new ContentPage());
var contentPage1 = new ContentPage();
var navigationPage = new TestNavigationPage(true, contentPage1);
Assert.ThrowsAsync<InvalidOperationException>(() => window.Navigation.PushAsync(contentPage1));
}

[Fact]
public async Task TabBarSetsOnFlyoutPageInsideModalPage()
{
Expand Down