dotnet / dotnet/maui

Application.ModalPopped never fires when run in Unit Test.

Open
#6,971 8 comments 0 reactions 0 assignees View on GitHub
area-controls-modal partner s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 10h
Merged PRs (30d)
297

Description

### Description

I'm working on porting the [KAMISHIBAI](https://github.com/nuitsjp/KAMISHIBAI) MVVM library from Xamarin.Forms to MAUI. I've bumped the version of Xamarin.Forms to the newest stable release and all of the tests pass. However, switching it over to MAUl, I have some failures.

In `ApplicationAdapter_ModalPopped`, the current `Application` should be posting an event when a modal window closes. This event never fires. For the Forms tests, this code works fine.

I made a MAUI Repo project where I attached to Application.ModalPopped, and those did fire correctly. But if I run the same code from a unit test project, it doesn't work.

[MauiTempTest.zip](https://github.com/dotnet/maui/files/8655781/MauiTempTest.zip)

Any ideas?

![image](https://user-images.githubusercontent.com/898335/167504736-79f6de49-0f0b-41d7-84ea-99e159776c78.png)

![image](https://user-images.githubusercontent.com/898335/167504717-3819e62e-be21-4bf0-a713-427c19d79f4d.png)

CC @nuitsjp, since it's your library.

### Steps to Reproduce

1. Check out my branch (https://github.com/drasticactions/KAMISHIBAI/tree/maui-port/MAUI/Source)
2. Open the solution
3. Run the test `ApplicationAdapter_ModalPopped`

It shouldn't require extra dependencies or special versions of MAUI.

### Version with bug

Release Candidate 2 (current)

### Last version that worked well

Unknown/Other

### Affected platforms

I was *not* able test on other platforms

### Affected platform versions

This affects Testing Libraries. As far as I can tell, it does not affect the platforms themselves.

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.