-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: GetCurrentPage for PrismWindow.Page throwing exception #3147
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9677d47
fix: GetCurrentPage for PrismWindow.Page throwing exception
RLittlesII b6ddf02
switched to expression
RLittlesII 80d9d91
Dan wants the exception
RLittlesII 997a0bd
Window has a Page!
RLittlesII a9d344e
convert fact to theory
RLittlesII f757300
separate tests
RLittlesII c007c9f
add skipped tabbed page tests
RLittlesII File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
135 changes: 135 additions & 0 deletions
135
tests/Maui/Prism.Maui.Tests/Fixtures/Common/MvvmHelperFixture.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,135 @@ | ||
using Prism.Common; | ||
|
||
namespace Prism.Maui.Tests.Fixtures.Common; | ||
|
||
public class MvvmHelperFixture | ||
{ | ||
/// <summary> | ||
/// This test was introduced to verify GH3143 | ||
/// </summary> | ||
/// <a href="https://github.com/PrismLibrary/Prism/issues/3143">Git Hub Issue 3143</a> | ||
[Fact] | ||
public async Task GetCurrentPageFromFlyoutPageWithModalReturnsDetailPage() | ||
{ | ||
// Given | ||
var flyout = new FlyoutPage | ||
{ Flyout = new ContentPage { Title = "Title" }, Detail = new NavigationPage(), }; | ||
var window = new PrismWindow { Page = flyout }; | ||
await window.Navigation.PushModalAsync(new DialogContainerPage()); | ||
|
||
// When | ||
var result = MvvmHelpers.GetCurrentPage(window.Page); | ||
|
||
// Then | ||
Assert.Equal(flyout.Detail, result); | ||
} | ||
|
||
/// <summary> | ||
/// This test was introduced to verify GH3143 | ||
/// </summary> | ||
/// <a href="https://github.com/PrismLibrary/Prism/issues/3143">Git Hub Issue 3143</a> | ||
[Fact] | ||
public async Task GetCurrentPageFromComplexFlyoutPageWithModalReturnsCorrectPage() | ||
{ | ||
// Given | ||
var expected = new ContentPage { Title = "D" }; | ||
var navigationPage = new NavigationPage(); | ||
await navigationPage.PushAsync(new ContentPage { Title = "A" }); | ||
await navigationPage.PushAsync(new ContentPage { Title = "B" }); | ||
await navigationPage.PushAsync(new ContentPage { Title = "C" }); | ||
await navigationPage.PushAsync(expected); | ||
|
||
var window = new Window | ||
{ | ||
Page = new FlyoutPage | ||
{ Flyout = new ContentPage { Title = "Title" }, Detail = navigationPage, } | ||
}; | ||
|
||
await window.Navigation.PushModalAsync(new DialogContainerPage()); | ||
|
||
// When | ||
var result = MvvmHelpers.GetCurrentPage(window.Page); | ||
|
||
// Then | ||
Assert.Equal(expected, result); | ||
} | ||
|
||
/// <summary> | ||
/// This test was introduced to verify GH3143 | ||
/// </summary> | ||
/// <a href="https://github.com/PrismLibrary/Prism/issues/3143">Git Hub Issue 3143</a> | ||
[Fact] | ||
public async Task GetCurrentPageFromNavigationPageWithModalReturnsContentPage() | ||
{ | ||
// Given | ||
var expected = new ContentPage(); | ||
var window = new Window { Page = new NavigationPage(expected) }; | ||
await window.Navigation.PushModalAsync(new DialogContainerPage()); | ||
|
||
// When | ||
var result = MvvmHelpers.GetCurrentPage(window.Page); | ||
|
||
// Then | ||
Assert.Equal(expected, result); | ||
} | ||
|
||
/// <summary> | ||
/// This test was introduced to verify GH3143 | ||
/// </summary> | ||
/// <a href="https://github.com/PrismLibrary/Prism/issues/3143">Git Hub Issue 3143</a> | ||
[Fact] | ||
public async Task GetCurrentPageFromContentPageWithModalReturnsContentPage() | ||
{ | ||
// Given | ||
var expected = new ContentPage { Title = "Title" }; | ||
var window = new Window { Page = expected }; | ||
await window.Navigation.PushModalAsync(new DialogContainerPage()); | ||
|
||
// When | ||
var result = MvvmHelpers.GetCurrentPage(window.Page); | ||
|
||
// Then | ||
Assert.Equal(expected, result); | ||
} | ||
|
||
/// <summary> | ||
/// This test was introduced to verify GH3143 | ||
/// </summary> | ||
/// <a href="https://github.com/PrismLibrary/Prism/issues/3143">Git Hub Issue 3143</a> | ||
[Fact(Skip = "System.InvalidOperationException\nBindableObject was not instantiated on a thread with a dispatcher nor does the current application have a dispatcher.")] | ||
public async Task GetCurrentPageFromTabbedPageWithModalReturnsContentPage() | ||
{ | ||
// Given | ||
var expected = new ContentPage(); | ||
var tabbedPage = new TabbedPage { Title = "Tab", Children = { expected }}; | ||
var window = new Window { Page = tabbedPage }; | ||
await window.Navigation.PushModalAsync(new DialogContainerPage()); | ||
|
||
// When | ||
var result = MvvmHelpers.GetCurrentPage(window.Page); | ||
|
||
// Then | ||
Assert.Equal(expected, result); | ||
} | ||
|
||
/// <summary> | ||
/// This test was introduced to verify GH3143 | ||
/// </summary> | ||
/// <a href="https://github.com/PrismLibrary/Prism/issues/3143">Git Hub Issue 3143</a> | ||
[Fact(Skip = "System.InvalidOperationException\nBindableObject was not instantiated on a thread with a dispatcher nor does the current application have a dispatcher.")] | ||
public async Task GetCurrentPageFromTabbedNavigationPageWithModalReturnsContentPage() | ||
{ | ||
// Given | ||
var expected = new ContentPage(); | ||
var navigationPage = new NavigationPage(expected); | ||
var tabbedPage = new TabbedPage { Title = "Tab", Children = { navigationPage }}; | ||
var window = new Window { Page = tabbedPage }; | ||
await window.Navigation.PushModalAsync(new DialogContainerPage()); | ||
|
||
// When | ||
var result = MvvmHelpers.GetCurrentPage(window.Page); | ||
|
||
// Then | ||
Assert.Equal(expected, result); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @Redth @PureWeen