1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Navigation
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
..
TestSceneBeatmapEditorNavigation.cs Fix test step name 2023-05-24 20:18:36 +02:00
TestSceneButtonSystemNavigation.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSceneChangeAndUseGameplayBindings.cs Move KeyCounter components to HUD namespace 2023-03-07 16:41:39 +09:00
TestSceneEditDefaultSkin.cs Move skin editor to overlays namespace 2023-02-02 14:00:31 +09:00
TestSceneFirstRunGame.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSceneInterProcessCommunication.cs Add test for ArchiveImportIPCChannel 2023-02-03 18:39:46 +01:00
TestSceneMouseWheelVolumeAdjust.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSceneOsuGame.cs Partial everything 2022-11-27 00:00:27 +09:00
TestScenePerformFromScreen.cs Partial everything 2022-11-27 00:00:27 +09:00
TestScenePresentBeatmap.cs Merge branch 'master' into update-framework 2022-11-26 16:19:36 +01:00
TestScenePresentScore.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSceneScreenNavigation.cs Fix screen navigation test hijacking dummy request handler 2023-06-05 23:15:16 +02:00
TestSceneSkinEditorNavigation.cs Add failing test coverage for clearing sidebar contents 2023-03-04 14:08:50 +01:00
TestSceneStartupBeatmapDisplay.cs Apply NRT to BeatmapPicker 2023-01-15 15:09:25 -08:00
TestSceneStartupBeatmapSetDisplay.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSceneStartupImport.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSceneStartupRuleset.cs Partial everything 2022-11-27 00:00:27 +09:00
TestSettingsMigration.cs Partial everything 2022-11-27 00:00:27 +09:00