Skip to content

Commit

Permalink
UI Test: Support high dpi displays for UI testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jbe2277 committed Jul 16, 2024
1 parent 60e0e2d commit 656e62e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Samples.UITest/UITest.Core/UITestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Xunit.Abstractions;

namespace UITest;
Expand All @@ -17,6 +18,7 @@ public abstract class UITestBase : IDisposable

static UITestBase()
{
NativeMethods.SetProcessDPIAware();
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");

Mouse.MovePixelsPerMillisecond = 2;
Expand Down Expand Up @@ -111,4 +113,11 @@ public void Dispose()
if (File.Exists(file)) File.Delete(file);
}
}


private static class NativeMethods
{
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SetProcessDPIAware();
}
}

0 comments on commit 656e62e

Please sign in to comment.