From 06035f5901cf95203f845f037e09ceb3e031a956 Mon Sep 17 00:00:00 2001
From: goat <16760685+goaaats@users.noreply.github.com>
Date: Thu, 19 Aug 2021 22:57:17 +0200
Subject: [PATCH] feat: add Handled Exception self-test step
---
.../AgingSteps/HandledExceptionAgingStep.cs | 35 +++++++++++++++++++
.../Windows/SelfTest/SelfTestWindow.cs | 1 +
2 files changed, 36 insertions(+)
create mode 100644 Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/HandledExceptionAgingStep.cs
diff --git a/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/HandledExceptionAgingStep.cs b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/HandledExceptionAgingStep.cs
new file mode 100644
index 000000000..cf64b03c3
--- /dev/null
+++ b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/HandledExceptionAgingStep.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
+{
+ ///
+ /// Test dedicated to handling of Access Violations.
+ ///
+ internal class HandledExceptionAgingStep : IAgingStep
+ {
+ ///
+ public string Name => "Test Handled Exception";
+
+ ///
+ public SelfTestStepResult RunStep(Dalamud dalamud)
+ {
+ try
+ {
+ Marshal.ReadByte(IntPtr.Zero);
+ }
+ catch (AccessViolationException)
+ {
+ return SelfTestStepResult.Pass;
+ }
+
+ return SelfTestStepResult.Fail;
+ }
+
+ ///
+ public void CleanUp(Dalamud dalamud)
+ {
+ // ignored
+ }
+ }
+}
diff --git a/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs b/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs
index 0f369b5ee..9f95c4d27 100644
--- a/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs
@@ -39,6 +39,7 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest
new HoverAgingStep(),
new LuminaAgingStep(),
new PartyFinderAgingStep(),
+ new HandledExceptionAgingStep(),
new LogoutEventAgingStep(),
};