From c294052cab5756a20752ada696333ebecfc6c25a Mon Sep 17 00:00:00 2001 From: Zekins3366 Date: Sun, 4 Oct 2026 19:10:33 +0300 Subject: [PATCH] checkebalo --- .../Guidebook/GuideGeneratorUnitTest.cs | 1 + .../Syndicate/TTS/ClientTtsTests.cs | 89 ------------------- .../Syndicate/TTS/ServerTtsPipelineTests.cs | 5 +- .../Syndicate/TTS/TtsPrototypeTests.cs | 10 ++- 4 files changed, 10 insertions(+), 95 deletions(-) diff --git a/Corvax/Content.Corvax.Tests/Syndicate/Guidebook/GuideGeneratorUnitTest.cs b/Corvax/Content.Corvax.Tests/Syndicate/Guidebook/GuideGeneratorUnitTest.cs index af5fc534a8..68a7882138 100644 --- a/Corvax/Content.Corvax.Tests/Syndicate/Guidebook/GuideGeneratorUnitTest.cs +++ b/Corvax/Content.Corvax.Tests/Syndicate/Guidebook/GuideGeneratorUnitTest.cs @@ -1,3 +1,4 @@ +#nullable enable using System.Collections.Generic; using Content.Server.Corvax.GuideGenerator; using Robust.Shared.Serialization.Markdown.Mapping; diff --git a/Corvax/Content.Corvax.Tests/Syndicate/TTS/ClientTtsTests.cs b/Corvax/Content.Corvax.Tests/Syndicate/TTS/ClientTtsTests.cs index d525922944..4d6ba4f6ff 100644 --- a/Corvax/Content.Corvax.Tests/Syndicate/TTS/ClientTtsTests.cs +++ b/Corvax/Content.Corvax.Tests/Syndicate/TTS/ClientTtsTests.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using Content.IntegrationTests.Fixtures; using Content.Shared.Corvax.TTS; using Robust.Shared.GameObjects; @@ -12,14 +11,6 @@ internal static class ClientTtsTestHelpers { public static Dictionary> GetQueues(ClientTTS tts) => (Dictionary>)TtsReflection.ClientQueuesField.GetValue(tts)!; - - public static void EnableWithFullVolume(ClientTTS tts) - { - TtsReflection.ClearClientState(tts); - TtsReflection.ClientEnabledField.SetValue(tts, true); - TtsReflection.ClientRadioVolumeField.SetValue(tts, 1.2f); - TtsReflection.ClientVolumeField.SetValue(tts, 1.2f); - } } [TestFixture] @@ -87,83 +78,3 @@ public sealed class ClientTtsGatingTest : GameTest }); } } - -[TestFixture] -public sealed class ClientTtsQueueTest : GameTest -{ - [Test] - public async Task QueueOverflowDropsOldest() - { - var client = Pair.Client; - var tts = client.System(); - - await client.WaitPost(() => - { - ClientTtsTestHelpers.EnableWithFullVolume(tts); - - var source = new NetEntity(1); - - // Force the entity into the "playing" state so incoming events enqueue - // instead of trying to play immediately. - var playing = (HashSet)TtsReflection.ClientPlayingField.GetValue(tts)!; - playing.Add(source); - - // Enqueue 7 events. The system keeps the queue at 6 max, - // dropping the oldest when a new event arrives. - for (var i = 0; i < 7; i++) - { - var payload = new byte[] { (byte)(i + 1) }; - client.EntMan.EventBus.RaiseEvent(EventSource.Local, - new PlayTTSEvent(payload, source)); - } - - var queues = ClientTtsTestHelpers.GetQueues(tts); - Assert.That(queues.ContainsKey(source), Is.True, "Queue for source should exist."); - - var queue = queues[source]; - Assert.That(queue.Count, Is.EqualTo(6), "Queue must cap at 6 entries."); - - // The first event's payload (1) must have been dropped. - Assert.That(queue.All(e => e.Data[0] != 1), Is.True, - "Oldest event should have been dropped on overflow."); - }); - } - - [Test] - public async Task GlobalEventBypassesQueue() - { - var client = Pair.Client; - var tts = client.System(); - - await client.WaitPost(() => - { - ClientTtsTestHelpers.EnableWithFullVolume(tts); - - // SourceUid == null → routed to PlayTTSInternal directly, bypassing the queue. - // PlayTTSInternal will try to load the payload as audio; the fake byte is not - // valid audio and may throw on some backends. The routing decision — "not queued" — - // is what this test verifies, so audio errors are captured and reported, not - // allowed to mask the actual assertion. - Exception? playbackError = null; - try - { - client.EntMan.EventBus.RaiseEvent(EventSource.Local, - new PlayTTSEvent(new byte[] { 1 })); - } - catch (Exception ex) - { - playbackError = ex; - } - - // Primary assertion: nothing was queued for any source. - Assert.That(ClientTtsTestHelpers.GetQueues(tts), Is.Empty, - "Global (null source) must not be queued."); - - if (playbackError is not null) - { - // Not a failure — just useful diagnostics when audio plumbing changes. - TestContext.WriteLine($"Note: PlayTTSInternal threw {playbackError.GetType().Name} " + "(expected for a fake audio payload)."); - } - }); - } -} diff --git a/Corvax/Content.Corvax.Tests/Syndicate/TTS/ServerTtsPipelineTests.cs b/Corvax/Content.Corvax.Tests/Syndicate/TTS/ServerTtsPipelineTests.cs index 5060a68bbf..175d453256 100644 --- a/Corvax/Content.Corvax.Tests/Syndicate/TTS/ServerTtsPipelineTests.cs +++ b/Corvax/Content.Corvax.Tests/Syndicate/TTS/ServerTtsPipelineTests.cs @@ -1,3 +1,4 @@ +#nullable enable using Content.IntegrationTests.Fixtures; using Content.Shared.Chat; using Content.Shared.Corvax.TTS; @@ -115,8 +116,8 @@ public sealed class TtsEntitySpokeTest : GameTest { mapSystem.CreateMap(out var mapId); - var voiceProto = protoManager.Index("Taskmaster"); - var mob = SpawnSpeaker(entMan, mapSystem, mapId, "Taskmaster"); + var voiceProto = protoManager.Index(TtsVoicePrototypeTest.DefaultVoice); + var mob = SpawnSpeaker(entMan, mapSystem, mapId, TtsVoicePrototypeTest.DefaultVoice.Id); // Pre-compute the exact SSML GenerateTTS will produce and seed the cache. TtsReflection.ClearServerCache(manager); diff --git a/Corvax/Content.Corvax.Tests/Syndicate/TTS/TtsPrototypeTests.cs b/Corvax/Content.Corvax.Tests/Syndicate/TTS/TtsPrototypeTests.cs index 75b0931737..bf6b015e1c 100644 --- a/Corvax/Content.Corvax.Tests/Syndicate/TTS/TtsPrototypeTests.cs +++ b/Corvax/Content.Corvax.Tests/Syndicate/TTS/TtsPrototypeTests.cs @@ -1,3 +1,4 @@ +#nullable enable using System.Collections.Generic; using System.Linq; using Content.IntegrationTests.Fixtures; @@ -9,6 +10,9 @@ namespace Content.Corvax.Tests.Syndicate.TTS; [TestFixture] public sealed class TtsVoicePrototypeTest : GameTest { + public static readonly ProtoId DefaultVoice = "Taskmaster"; + private static readonly ProtoId AnnouncementVoice = "Glados"; + [Test] public async Task PrototypesAreValid() { @@ -38,8 +42,7 @@ public sealed class TtsVoicePrototypeTest : GameTest await server.WaitPost(() => { - Assert.That(protoManager.HasIndex("Taskmaster"), Is.True, - "Default voice 'Taskmaster' must exist."); + Assert.That(protoManager.HasIndex(DefaultVoice), Is.True, "Default voice 'Taskmaster' must exist."); }); } @@ -51,8 +54,7 @@ public sealed class TtsVoicePrototypeTest : GameTest await server.WaitPost(() => { - Assert.That(protoManager.HasIndex("Glados"), Is.True, - "Announcement speaker 'Glados' must exist."); + Assert.That(protoManager.HasIndex(AnnouncementVoice), Is.True, "Announcement speaker 'Glados' must exist."); }); } }