From 1f70320ea873a40c81c8f920900d119e2d50c9c2 Mon Sep 17 00:00:00 2001 From: James Groom Date: Thu, 7 Mar 2024 06:54:16 +0000 Subject: [PATCH] Get testroms projects building again fixes 8ae947fed, e87536ea8, e7f4ad822, 59fcdb04c, 72cc19266, d788e603f, and 86684b689 --- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 5 +- .../.run_tests_with_configuration.sh | 6 +- .../BizHawk.Tests.Testroms.GB.csproj | 2 + .../DummyFrontend.cs | 96 +++++++------------ 4 files changed, 44 insertions(+), 65 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index eead1f2c06..4fd8d8a93c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -17,6 +17,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [ServiceNotApplicable(new[] { typeof(IDriveLight) })] public partial class Gameboy : IInputPollable, IRomInfo, IGameboyCommon, ICycleTiming, ILinkable { + /// HACK disables BIOS requirement if the environment looks like a test runner... + private static readonly bool TestromsBIOSDisableHack = Type.GetType("Microsoft.VisualStudio.TestTools.UnitTesting.Assert, Microsoft.VisualStudio.TestPlatform.TestFramework") is not null; + [CoreConstructor(VSystemID.Raw.GB)] [CoreConstructor(VSystemID.Raw.GBC)] [CoreConstructor(VSystemID.Raw.SGB)] @@ -132,7 +135,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy return true; } - var useBios = _syncSettings.EnableBIOS || ForceBios(); + var useBios = _syncSettings.EnableBIOS || (!TestromsBIOSDisableHack && ForceBios()); if (useBios) { FirmwareID fwid = new( diff --git a/src/BizHawk.Tests.Testroms.GB/.run_tests_with_configuration.sh b/src/BizHawk.Tests.Testroms.GB/.run_tests_with_configuration.sh index 65116168d7..bb84019491 100755 --- a/src/BizHawk.Tests.Testroms.GB/.run_tests_with_configuration.sh +++ b/src/BizHawk.Tests.Testroms.GB/.run_tests_with_configuration.sh @@ -5,4 +5,8 @@ config="$1" shift res/download_from_ci.sh export LD_LIBRARY_PATH="$root/output/dll:$LD_LIBRARY_PATH" -dotnet test -a "$root/test_output" -c "$config" -l "junit;LogFilePath=$root/test_output/{assembly}.coverage.xml;MethodFormat=Class;FailureBodyFormat=Verbose" -l "console;verbosity=detailed" "$@" +dotnet test -c "$config" \ + -l "junit;LogFilePath=$root/test_output/{assembly}.coverage.xml;MethodFormat=Class;FailureBodyFormat=Verbose" \ + -l "console;verbosity=detailed" \ + --test-adapter-path "$root/test_output" \ + "$@" diff --git a/src/BizHawk.Tests.Testroms.GB/BizHawk.Tests.Testroms.GB.csproj b/src/BizHawk.Tests.Testroms.GB/BizHawk.Tests.Testroms.GB.csproj index a6ebf77a5b..37aaa0d70f 100644 --- a/src/BizHawk.Tests.Testroms.GB/BizHawk.Tests.Testroms.GB.csproj +++ b/src/BizHawk.Tests.Testroms.GB/BizHawk.Tests.Testroms.GB.csproj @@ -4,6 +4,7 @@ + $(NoWarn);CA1310;CA1416 $(ProjectDir)../../test_output @@ -22,6 +23,7 @@ + diff --git a/src/BizHawk.Tests.Testroms.GB/DummyFrontend.cs b/src/BizHawk.Tests.Testroms.GB/DummyFrontend.cs index 5cb80b5adf..83ea9d2f38 100644 --- a/src/BizHawk.Tests.Testroms.GB/DummyFrontend.cs +++ b/src/BizHawk.Tests.Testroms.GB/DummyFrontend.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using BizHawk.Bizware.BizwareGL; +using BizHawk.Bizware.Graphics; using BizHawk.Client.Common; using BizHawk.Common.IOExtensions; using BizHawk.Emulation.Common; @@ -73,77 +74,41 @@ namespace BizHawk.Tests.Testroms.GB public string GetRetroSystemPath(IGameInfo game) => throw new NotImplementedException(); - } - private sealed class FakeGraphicsControl : IGraphicsControl - { - private readonly IGL_GdiPlus _gdi; - - private readonly Func<(int, int)> _getVirtualSize; - - public Rectangle ClientRectangle - { - get - { - var (w, h) = _getVirtualSize(); - return new(0, 0, w, h); - } - } - - public RenderTargetWrapper? RenderTargetWrapper { get; set; } - - public FakeGraphicsControl(IGL_GdiPlus glImpl, Func<(int Width, int Height)> getVirtualSize) - { - _gdi = glImpl; - _getVirtualSize = getVirtualSize; - } - - public void Begin() - { - _gdi.BeginControl(this); - RenderTargetWrapper!.CreateGraphics(); - } - - public Graphics CreateGraphics() - { - var (w, h) = _getVirtualSize(); - return Graphics.FromImage(new Bitmap(w, h)); - } - - public void End() - => _gdi.EndControl(this); - - public void SetVsync(bool state) {} - - public void SwapBuffers() - { - _gdi.SwapControl(this); - if (RenderTargetWrapper!.MyBufferedGraphics is null) return; - RenderTargetWrapper.CreateGraphics(); - } - - public void Dispose() {} + public string GetUserPath(string sysID, bool temp) + => throw new NotImplementedException(); // only used by Encore } public sealed class SimpleGDIPDisplayManager : DisplayManagerBase { - private readonly FakeGraphicsControl _gc; - - private SimpleGDIPDisplayManager(Config config, IEmulator emuCore, IGL_GdiPlus glImpl) - : base(config, emuCore, inputManager: null, movieSession: null, EDispMethod.GdiPlus, glImpl, new GDIPlusGuiRenderer(glImpl)) - { - _gc = (FakeGraphicsControl) glImpl.Internal_CreateGraphicsControl(); - Blank(); - } + private SimpleGDIPDisplayManager(Config config, IEmulator emuCore, IGL_GDIPlus glImpl) + : base( + config, + emuCore, + inputManager: null, + movieSession: null, + EDispMethod.GdiPlus, + glImpl, + new GDIPlusGuiRenderer(glImpl)) + {} public SimpleGDIPDisplayManager(Config config, IEmulator emuCore, Func<(int Width, int Height)> getVirtualSize) - : this(config, emuCore, new IGL_GdiPlus(self => new FakeGraphicsControl(self, getVirtualSize))) {} + : this(config, emuCore, new IGL_GDIPlus()) {} - protected override void ActivateGLContext() - => _gc.Begin(); + protected override void ActivateGraphicsControlContext() {} - protected override void SwapBuffersOfGraphicsControl() - => _gc.SwapBuffers(); + public override void ActivateOpenGLContext() {} + + protected override Size GetGraphicsControlSize() + => throw new NotImplementedException(); + + public override Size GetPanelNativeSize() + => throw new NotImplementedException(); + + protected override Point GraphicsControlPointToClient(Point p) + => throw new NotImplementedException(); + + protected override void SwapBuffersOfGraphicsControl() {} } private static int _totalFrames = 0; @@ -198,7 +163,12 @@ namespace BizHawk.Tests.Testroms.GB var (core, biosWaitDuration) = init( efp, _config, - new(Console.WriteLine, (s, _) => Console.WriteLine(s), efp, CoreComm.CorePreferencesFlags.None)); + new( + Console.WriteLine, + (s, _) => Console.WriteLine(s), + efp, + CoreComm.CorePreferencesFlags.None, + oglProvider: null!)); Core = core; _controller = new(Core.ControllerDefinition); FrameAdvanceTo(biosWaitDuration);