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
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public ShellFragmentContainer(ShellContent shellContent, IMauiContext mauiContex
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
_page = ((IShellContentController)ShellContentTab).GetOrCreateContent();

var pageMauiContext = _mauiContext.MakeScoped(layoutInflater: inflater, fragmentManager: ChildFragmentManager);

return new ShellPageContainer(RequireContext(), (IPlatformViewHandler)_page.ToHandler(pageMauiContext), true)
{
LayoutParameters = new LP(LP.MatchParent, LP.MatchParent)
Expand All @@ -40,7 +40,9 @@ public override void OnDestroyView()

public override void OnDestroy()
{
Activity.RunOnUiThread(Dispose);
_mauiContext
.GetDispatcher()
.Dispatch(Dispose);

base.OnDestroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ protected virtual void HookChildEvents(ShellSection shellSection)

protected virtual void OnShellSectionChanged()
{
HandleFragmentUpdate(ShellNavigationSource.ShellSectionChanged, ShellSection, null, false);
HandleFragmentUpdate(ShellNavigationSource.ShellSectionChanged, ShellSection, null, false).FireAndForget();
}

protected virtual void OnDisplayedPageChanged(Page newPage, Page oldPage)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;

namespace Microsoft.Maui.DeviceTests
{
public class ShellBasicNavigationTestCases : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
{
var page1 = new ContentPage();
var page2 = new ContentPage();

yield return new object[] { new ShellItem[]
{
new ShellItem() { Items = { page1 }, Route = "page1" },
new ShellItem() { Items = { page2 }, Route = "page2" }
} };

yield return new object[] {new ShellItem[]
{
new ShellSection() { Items = { page1 }, Route = "page1" },
new ShellSection() { Items = { page2 }, Route = "page2" }
} };

yield return new object[] { new ShellItem[]
{
new ShellContent() { Content = page1, Route = "page1" },
new ShellContent() { Content = page2, Route = "page2" }
} };

yield return new object[] { new ShellItem[]
{
new FlyoutItem()
{
Items =
{
new ShellContent() { Content = page1, Route = "page1" },
new ShellContent() { Content = page2, Route = "page2" },
new ShellContent() { Content = new ContentPage(), Route = "page3" },
}
}
} };
}

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
38 changes: 32 additions & 6 deletions src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,46 @@ public async Task DetailsViewUpdates()
{
SetupBuilder();

var shell = await InvokeOnMainThreadAsync<Shell>(() => {
var shell = await InvokeOnMainThreadAsync<Shell>(() =>
{
return new Shell()
{
Items =
{
Items =
{
new ContentPage()
}
};
};
});

await CreateHandlerAndAddToWindow<ShellHandler>(shell, (handler) =>
await CreateHandlerAndAddToWindow<ShellHandler>(shell, async (handler) =>
{
// TODO MAUI Fix this
await Task.Delay(100);
Assert.NotNull(shell.Handler);
return Task.CompletedTask;
});
}


[Theory]
[ClassData(typeof(ShellBasicNavigationTestCases))]
public async Task BasicShellNavigationStructurePermutations(ShellItem[] shellItems)
{
SetupBuilder();
var shell = await InvokeOnMainThreadAsync<Shell>(() =>
{
var value = new Shell();
foreach (var item in shellItems)
value.Items.Add(item);

return value;
});

await CreateHandlerAndAddToWindow<ShellHandler>(shell, async (handler) =>
{
// TODO MAUI Fix this
await Task.Delay(100);
await shell.GoToAsync("//page2");
await Task.Delay(100);
});
}
#endif
Expand Down