-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Fix crash adding items to CollectionView on navigating (#13385
) Fixes #12219 * Fix crash adding items to CollectionView on Android navigating * Changes in test
- Loading branch information
1 parent
b34ef5e
commit 2a15957
Showing
4 changed files
with
63 additions
and
2 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
51 changes: 49 additions & 2 deletions
51
src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.Android.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 |
---|---|---|
@@ -1,7 +1,54 @@ | ||
namespace Microsoft.Maui.DeviceTests | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Handlers; | ||
using Xunit; | ||
|
||
namespace Microsoft.Maui.DeviceTests | ||
{ | ||
public partial class CollectionViewTests | ||
public partial class CollectionViewTests : ControlsHandlerTestBase | ||
{ | ||
[Fact] | ||
public async Task PushAndPopPageWithCollectionView() | ||
{ | ||
NavigationPage rootPage = new NavigationPage(new ContentPage()); | ||
ContentPage modalPage = new ContentPage(); | ||
|
||
var collectionView = new CollectionView | ||
{ | ||
ItemsSource = new string[] | ||
{ | ||
"Item 1", | ||
"Item 2", | ||
"Item 3", | ||
} | ||
}; | ||
|
||
modalPage.Content = collectionView; | ||
|
||
SetupBuilder(); | ||
|
||
await CreateHandlerAndAddToWindow<IWindowHandler>(rootPage, | ||
async (_) => | ||
{ | ||
var currentPage = (rootPage as IPageContainer<Page>).CurrentPage; | ||
|
||
await currentPage.Navigation.PushModalAsync(modalPage); | ||
await OnLoadedAsync(modalPage); | ||
|
||
await currentPage.Navigation.PopModalAsync(); | ||
await OnUnloadedAsync(modalPage); | ||
|
||
// Navigate a second time | ||
await currentPage.Navigation.PushModalAsync(modalPage); | ||
await OnLoadedAsync(modalPage); | ||
|
||
await currentPage.Navigation.PopModalAsync(); | ||
await OnUnloadedAsync(modalPage); | ||
}); | ||
|
||
|
||
// Without Exceptions here, the test has passed. | ||
Assert.Equal(0, (rootPage as IPageContainer<Page>).CurrentPage.Navigation.ModalStack.Count); | ||
} | ||
} | ||
} |
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