using System.Windows.Forms; using UnitTestSharp; namespace Blacklight.SharpDX9.UnitTesting { public class SharpDX9WindowHandleTests : TestFixture { public class WaitForGpuTests : TestFixture { private Form window; private SharpDX9WindowHandle handle; public override void FixtureTeardown() { handle?.Dispose(); window?.Dispose(); } // Creating the real device (shader compile, driver init) alone burns past the framework's fixed // 500ms setup/teardown budget, so it happens here in the timed, [CpuTimeout]-widened test body // instead of FixtureSetup: the first of the repeated AllocationTest calls pays for it once, and every // call after reuses the same handle, which is exactly the steady state this test measures. [AllocationTest] [CpuTimeout(5000)] public void AllocatesNothingOnceWarm() { if (handle == null) { window = new Form(); handle = (SharpDX9WindowHandle)new Module().CreateDrawableSurfaceOnWindow(window.Handle); handle.MeasureGpuCompletion = true; } handle.WaitForGpu(); CheckNoAllocations(); } } } }