1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:07:52 +08:00
osu-lazer/osu.Game.Tests
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 Remove the nullable disable annotation in the test project. 2022-07-31 22:02:07 +08:00
Beatmaps Merge branch 'master' into sample-set-controls 2023-05-24 14:03:04 +09:00
Chat Fix channel manager test scene not waiting for notifications client connection 2023-01-12 23:14:23 +03:00
Collections/IO Remove redundant parameters 2022-10-29 00:24:33 +09:00
Database ExportToStream should be public 2023-05-05 21:28:43 +09:00
Editing Update CheckMutedObjectsTest.cs 2023-04-29 23:52:30 +02:00
Extensions Add own fixed copy of defective Humanizer methods 2022-07-18 21:37:31 +02:00
Gameplay Add xmldoc and change naming around ScoreProcessorStatistics a bit 2023-05-29 18:38:16 +09:00
Input Partial everything 2022-11-27 00:00:27 +09:00
Localisation Automated #nullable processing 2022-06-17 16:37:17 +09:00
Models Automated #nullable processing 2022-06-17 16:37:17 +09:00
Mods Add test coverage for mod equality with multiple settings 2023-05-04 20:46:27 +02:00
NonVisual Update test assertions to match stable expectations 2023-02-28 19:28:21 +09:00
Online Convert batchImport parameter to parameters class to allow further import configuration 2022-12-13 19:55:18 +09:00
OnlinePlay Partial everything 2022-11-27 00:00:27 +09:00
Resources Merge branch 'master' into scorev2 2023-05-23 19:07:54 +09:00
Rulesets Fix CI issues 2023-05-23 19:32:19 +09:00
Scores/IO Automated #nullable processing 2022-06-17 16:37:17 +09:00
ScrollAlgorithms Automated #nullable processing 2022-06-17 16:37:17 +09:00
Skins Merge remote-tracking branch 'upstream/master' into export 2023-04-09 15:02:47 +09:00
Testing Add missing ruleset shader tests 2023-05-02 11:55:05 +03:00
Utils add tests for GetNextBestFilename() 2022-12-01 18:48:25 +01:00
Visual Fix screen navigation test hijacking dummy request handler 2023-06-05 23:15:16 +02:00
ImportTest.cs Partial everything 2022-11-27 00:00:27 +09:00
osu.Game.Tests.csproj Re-centralise BannedApiAnalysers nuget package 2023-02-11 19:36:40 +09:00
tests.ruleset Exclude tests from ConfigureAwait rule 2021-03-08 14:36:35 +09:00
WaveformTestBeatmap.cs Automated #nullable processing 2022-06-17 16:37:17 +09:00