Skip to content
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

[net9.0] Enable back the failing Shell tests #22830

Draft
wants to merge 4 commits into
base: net9.0
Choose a base branch
from
Draft
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
42 changes: 21 additions & 21 deletions src/Controls/tests/Core.UnitTests/NavigationPageLifecycleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,33 @@ public async Task RemoveLastPage(bool useMaui)
Assert.Equal(1, pushedPage.DisappearingCount);
}

// [Theory]
// [InlineData(false)]
// [InlineData(true)]
// public async Task RemoveInnerPage(bool useMaui)
// {
// ContentPage initialPage = new ContentPage();
// ContentPage pushedPage = new ContentPage();
[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task RemoveInnerPage(bool useMaui)
{
ContentPage initialPage = new ContentPage();
ContentPage pushedPage = new ContentPage();

// ContentPage initialPageAppearing = null;
// ContentPage pageDisappeared = null;
ContentPage initialPageAppearing = null;
ContentPage pageDisappeared = null;

// NavigationPage nav = new TestNavigationPage(useMaui, initialPage);
// _ = new Window(nav);
// nav.SendAppearing();
NavigationPage nav = new TestNavigationPage(useMaui, initialPage);
_ = new Window(nav);
nav.SendAppearing();

// var pageToRemove = new ContentPage();
// await nav.PushAsync(pageToRemove);
// await nav.PushAsync(pushedPage);
var pageToRemove = new ContentPage();
await nav.PushAsync(pageToRemove);
await nav.PushAsync(pushedPage);


// initialPage.Appearing += (__, _)
// => throw new XunitException("Appearing Fired Incorrectly");
initialPage.Appearing += (__, _)
=> throw new XunitException("Appearing Fired Incorrectly");

// pushedPage.Disappearing += (__, _)
// => throw new XunitException("Appearing Fired Incorrectly");
pushedPage.Disappearing += (__, _)
=> throw new XunitException("Appearing Fired Incorrectly");

// nav.Navigation.RemovePage(pageToRemove);
// }
nav.Navigation.RemovePage(pageToRemove);
}
}
}
50 changes: 25 additions & 25 deletions src/Controls/tests/Core.UnitTests/ShellLifeCycleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,35 +164,35 @@ public async Task EnsureOnAppearingFiresForLastPageOnly()
Assert.True(page.Appearing);
}

// [Fact]
// public async Task EnsureOnAppearingFiresForLastPageOnlyAbsoluteRoute()
// {
// Shell shell = new TestShell();
// LifeCyclePage shellContentPage = new LifeCyclePage();
// shell.Items.Add(CreateShellItem());
// shell.Items.Add(CreateShellItem(page: shellContentPage, shellItemRoute: "ShellItemRoute"));
// await shell.GoToAsync("///ShellItemRoute/LifeCyclePage/LifeCyclePage");
[Fact]
public async Task EnsureOnAppearingFiresForLastPageOnlyAbsoluteRoute()
{
Shell shell = new TestShell();
LifeCyclePage shellContentPage = new LifeCyclePage();
shell.Items.Add(CreateShellItem());
shell.Items.Add(CreateShellItem(page: shellContentPage, shellItemRoute: "ShellItemRoute"));
await shell.GoToAsync("///ShellItemRoute/LifeCyclePage/LifeCyclePage");

// var page = (LifeCyclePage)shell.GetVisiblePage();
// var nonVisiblePage = (LifeCyclePage)shell.Navigation.NavigationStack[1];
var page = (LifeCyclePage)shell.GetVisiblePage();
var nonVisiblePage = (LifeCyclePage)shell.Navigation.NavigationStack[1];

// Assert.False(shellContentPage.Appearing);
// Assert.False(nonVisiblePage.Appearing);
// await page.AppearingTask.ConfigureAwait(false);
// Assert.True(page.Appearing);
// }
Assert.False(shellContentPage.Appearing);
Assert.False(nonVisiblePage.Appearing);
await page.AppearingTask.ConfigureAwait(false);
Assert.True(page.Appearing);
}


// [Fact]
// public async Task EnsureOnAppearingFiresForPushedPage()
// {
// Shell shell = new TestShell();
// shell.Items.Add(CreateShellItem());
// await shell.Navigation.PushAsync(new LifeCyclePage());
// var page = (LifeCyclePage)shell.GetVisiblePage();
// Assert.True(page.Appearing);
// Assert.True(page.ParentSet);
// }
[Fact]
public async Task EnsureOnAppearingFiresForPushedPage()
{
Shell shell = new TestShell();
shell.Items.Add(CreateShellItem());
await shell.Navigation.PushAsync(new LifeCyclePage());
var page = (LifeCyclePage)shell.GetVisiblePage();
Assert.True(page.Appearing);
Assert.True(page.ParentSet);
}

[Fact]
public async Task NavigatedFiresAfterContentIsCreatedWhenUsingTemplate()
Expand Down
102 changes: 51 additions & 51 deletions src/Controls/tests/Core.UnitTests/ShellNavigatedArgsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,57 +148,57 @@ await shell.TestNavigationArgs(ShellNavigationSource.Insert,
}


// [Fact]
// public async Task InsertPageFromNavigationSetsCorrectNavigationSource()
// {
// Routing.RegisterRoute("pagemiddle", typeof(ContentPage));
// Routing.RegisterRoute("page", typeof(ContentPage));
// var shell = new TestShell(
// CreateShellItem(shellItemRoute: "item")
// );

// await shell.GoToAsync("//item/page");
// ContentPage contentPage = new ContentPage();
// Routing.SetRoute(contentPage, "pagemiddle");
// shell.Navigation.InsertPageBefore(contentPage, shell.Navigation.NavigationStack.Last());

// await shell.TestNavigationArgs(ShellNavigationSource.Insert,
// "//item/page", "//item/pagemiddle/page");
// }


// [Fact]
// public async Task RemovePageFromNavigationSetsCorrectNavigationSource()
// {
// Routing.RegisterRoute("pagemiddle", typeof(ContentPage));
// Routing.RegisterRoute("page", typeof(ContentPage));
// var shell = new TestShell(
// CreateShellItem(shellItemRoute: "item")
// );

// await shell.GoToAsync("//item/pagemiddle/page");
// shell.Navigation.RemovePage(shell.Navigation.NavigationStack[1]);

// await shell.TestNavigationArgs(ShellNavigationSource.Remove,
// "//item/pagemiddle/page", "//item/page");
// }

// [Fact]
// public async Task RemovePageSetsCorrectNavigationSource()
// {
// Routing.RegisterRoute("pagemiddle", typeof(ContentPage));
// Routing.RegisterRoute("page", typeof(ContentPage));
// var shell = new TestShell(
// CreateShellItem(shellItemRoute: "item")
// );

// await shell.GoToAsync("//item/pagemiddle/page");
// await shell.GoToAsync("//item/page");


// await shell.TestNavigationArgs(ShellNavigationSource.Remove,
// "//item/pagemiddle/page", "//item/page");
// }
[Fact]
public async Task InsertPageFromNavigationSetsCorrectNavigationSource()
{
Routing.RegisterRoute("pagemiddle", typeof(ContentPage));
Routing.RegisterRoute("page", typeof(ContentPage));
var shell = new TestShell(
CreateShellItem(shellItemRoute: "item")
);

await shell.GoToAsync("//item/page");
ContentPage contentPage = new ContentPage();
Routing.SetRoute(contentPage, "pagemiddle");
shell.Navigation.InsertPageBefore(contentPage, shell.Navigation.NavigationStack.Last());

await shell.TestNavigationArgs(ShellNavigationSource.Insert,
"//item/page", "//item/pagemiddle/page");
}


[Fact]
public async Task RemovePageFromNavigationSetsCorrectNavigationSource()
{
Routing.RegisterRoute("pagemiddle", typeof(ContentPage));
Routing.RegisterRoute("page", typeof(ContentPage));
var shell = new TestShell(
CreateShellItem(shellItemRoute: "item")
);

await shell.GoToAsync("//item/pagemiddle/page");
shell.Navigation.RemovePage(shell.Navigation.NavigationStack[1]);

await shell.TestNavigationArgs(ShellNavigationSource.Remove,
"//item/pagemiddle/page", "//item/page");
}

[Fact]
public async Task RemovePageSetsCorrectNavigationSource()
{
Routing.RegisterRoute("pagemiddle", typeof(ContentPage));
Routing.RegisterRoute("page", typeof(ContentPage));
var shell = new TestShell(
CreateShellItem(shellItemRoute: "item")
);

await shell.GoToAsync("//item/pagemiddle/page");
await shell.GoToAsync("//item/page");


await shell.TestNavigationArgs(ShellNavigationSource.Remove,
"//item/pagemiddle/page", "//item/page");
}

[Fact]
public async Task InitialNavigatingArgs()
Expand Down
38 changes: 19 additions & 19 deletions src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -534,25 +534,25 @@ public async Task ShellItemContentRouteWithGlobalRouteRelative(bool modal, int d
Assert.Equal("//animals/monkeys/details", shell.CurrentState.Location.ToString());
}

//[Theory]
//[InlineData(true)]
//[InlineData(false)]
//public async Task GotoSameGlobalRoutesCollapsesUriCorrectly(bool modal)
//{
// var shell = new Shell();
// var item1 = CreateShellItem<FlyoutItem>(asImplicit: true, shellItemRoute: "animals", shellContentRoute: "monkeys");

// if (modal)
// Routing.RegisterRoute("details", typeof(ShellModalTests.ModalTestPage));
// else
// Routing.RegisterRoute("details", typeof(ContentPage));

// shell.Items.Add(item1);

// await shell.GoToAsync("details");
// await shell.GoToAsync("details");
// Assert.Equal("//animals/monkeys/details/details", shell.CurrentState.Location.ToString());
//}
[Theory]
[InlineData(true)]
[InlineData(false)]
public async Task GotoSameGlobalRoutesCollapsesUriCorrectly(bool modal)
{
var shell = new Shell();
var item1 = CreateShellItem<FlyoutItem>(asImplicit: true, shellItemRoute: "animals", shellContentRoute: "monkeys");

if (modal)
Routing.RegisterRoute("details", typeof(ShellModalTests.ModalTestPage));
else
Routing.RegisterRoute("details", typeof(ContentPage));

shell.Items.Add(item1);

await shell.GoToAsync("details");
await shell.GoToAsync("details");
Assert.Equal("//animals/monkeys/details/details", shell.CurrentState.Location.ToString());
}

[Fact]
public async Task ShellSectionWithGlobalRouteAbsolute()
Expand Down
35 changes: 17 additions & 18 deletions src/Controls/tests/Core.UnitTests/ShellTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,28 +1240,27 @@ public void ClearingShellSectionAndReAddingSetsCurrentItem()
Assert.NotNull(item.CurrentItem.CurrentItem);
}

// [Fact]

// public async Task GetCurrentPageInShellNavigation()
// {
// Shell shell = new TestShell();
// var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent1");
[Fact]
public async Task GetCurrentPageInShellNavigation()
{
Shell shell = new TestShell();
var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent1");

// shell.Items.Add(item1);
// Routing.RegisterRoute("cat", typeof(ContentPage));
shell.Items.Add(item1);
Routing.RegisterRoute("cat", typeof(ContentPage));

// Page page = null;
Page page = null;

// shell.Navigated += (_, __) =>
// {
// page = shell.CurrentPage;
// };
shell.Navigated += (_, __) =>
{
page = shell.CurrentPage;
};

// await shell.GoToAsync("cat");
// Assert.NotNull(page);
// Assert.IsType<ContentPage>(page);
// Assert.Equal(shell.Navigation.NavigationStack[1], page);
// }
await shell.GoToAsync("cat");
Assert.NotNull(page);
Assert.IsType<ContentPage>(page);
Assert.Equal(shell.Navigation.NavigationStack[1], page);
}

[Fact]
public async Task GetCurrentPageBetweenSections()
Expand Down
Loading