1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 10:02:59 +08:00
osu-lazer/osu.Game.Tests/Visual
Bartłomiej Dach 5c1abdc704
Fix screen navigation test hijacking dummy request handler
In an upcoming change, I stumbled upon a test failure mode wherein tests
in `TestSceneScreenNavigation` would die on the following exception:

	2023-05-07 17:58:42 [error]: System.ObjectDisposedException: Cannot access a closed Realm.
	2023-05-07 17:58:42 [error]: Object name: 'Realms.Realm'.
	2023-05-07 17:58:42 [error]: at Realms.Realm.ThrowIfDisposed()
	2023-05-07 17:58:42 [error]: at Realms.Realm.All[T]()
	2023-05-07 17:58:42 [error]: at osu.Game.Beatmaps.BeatmapManager.<>c__DisplayClass25_0.<QueryBeatmap>b__0(Realm r) in D:\a\osu\osu\osu.Game\Beatmaps\BeatmapManager.cs:line 282
	2023-05-07 17:58:42 [error]: at osu.Game.Database.RealmAccess.Run[T](Func`2 action) in D:\a\osu\osu\osu.Game\Database\RealmAccess.cs:line 387
	2023-05-07 17:58:42 [error]: at osu.Game.Beatmaps.BeatmapManager.QueryBeatmap(Expression`1 query) in D:\a\osu\osu\osu.Game\Beatmaps\BeatmapManager.cs:line 282
	2023-05-07 17:58:42 [error]: at osu.Game.Tests.Visual.OnlinePlay.TestRoomRequestsHandler.<HandleRequest>g__createResponseBeatmaps|6_0(Int32[] beatmapIds, <>c__DisplayClass6_0& ) in D:\a\osu\osu\osu.Game\Tests\Visual\OnlinePlay\TestRoomRequestsHandler.cs:line 174
	2023-05-07 17:58:42 [error]: at osu.Game.Tests.Visual.OnlinePlay.TestRoomRequestsHandler.HandleRequest(APIRequest request, APIUser localUser, BeatmapManager beatmapManager) in D:\a\osu\osu\osu.Game\Tests\Visual\OnlinePlay\TestRoomRequestsHandler.cs:line 140
	2023-05-07 17:58:42 [error]: at osu.Game.Tests.Visual.TestMultiplayerComponents.<>c__DisplayClass18_0.<load>b__0(APIRequest request) in D:\a\osu\osu\osu.Game.Tests\Visual\TestMultiplayerComponents.cs:line 80
	2023-05-07 17:58:42 [error]: at osu.Game.Online.API.DummyAPIAccess.<>c__DisplayClass32_0.<Queue>b__0() in D:\a\osu\osu\osu.Game\Online\API\DummyAPIAccess.cs:line 74

Upon closer inspection, one of the tests in the scene instantiates a
`TestMultiplayerComponents` instance. `TestMultiplayerComponents`
registers a custom request handler onto `DummyAPIAccess`. Normally, this
is not an issue; however, because `TestSceneScreenNavigation` is an
`OsuGameTestScene`, and therefore has its storage recycled after every
test, this leads to the error above in the following scenario:

1. `TestPushMatchSubScreenAndPressBackButtonImmediately()` passes.
2. The test is cleaned up, and the test case's storage is recycled,
   including the test case's realm database.
3. In a subsequent test, a web request handled by the dummy API request
   handler is fired. The dummy API request handler subsequently attempts
   to access a realm that does not exist anymore.

As the usage of `TestMultiplayerComponents` is highly unorthodox in this
particular case, I'm opting for a localised fix which ensures that the
request handler is cleaned up appropriately.
2023-06-05 23:15:16 +02:00
..
Audio Rename NormalSliderBar.cs to RoundedSliderBar.cs 2023-02-02 17:24:45 +01:00
Background Add second definition of EndTime for storyboard elements to account for loops in lifetime 2023-04-25 15:22:11 +09:00
Beatmaps Partial everything 2022-11-27 00:00:27 +09:00
Collections Add test coverage showing commit failure in manage collections dialog 2023-06-04 12:50:30 +09:00
Colours Partial everything 2022-11-27 00:00:27 +09:00
Components Partial everything 2022-11-27 00:00:27 +09:00
Editing Merge branch 'master' into slider-control-point-no-distance-snap 2023-05-26 19:52:54 +02:00
Gameplay Merge branch 'master' into scorev2 2023-05-29 20:06:32 +09:00
Menus Fix overlay toggle keys working during disabled activation modes 2023-04-03 15:03:47 +09:00
Mods Add testing 2023-05-29 22:33:46 +02:00
Multiplayer Merge branch 'master' into update-multiplayer-room-diff-range 2023-06-03 16:50:09 +02:00
Navigation Fix screen navigation test hijacking dummy request handler 2023-06-05 23:15:16 +02:00
Online Change "Show main page" test steps to actually load the main page 2023-05-08 15:32:00 +09:00
Playlists Fix intermittent failure in playlists match loading test 2023-01-20 01:18:41 +03:00
Ranking Return StatisticItems rather than StatisticRows from ruleset 2023-06-01 14:35:15 +09:00
Settings Remove all unnecessary usage of IHasFilterableChildren 2022-11-29 14:40:52 +09:00
SongSelect Fix TestSceneTopLocalRank 2023-05-19 14:06:56 +09:00
UserInterface Centralise beatmap playable duration and bounds lookups 2023-05-25 17:32:48 +09:00
TestMultiplayerComponents.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSceneOsuScreenStack.cs Partial everything 2022-11-27 00:00:27 +09:00