Skip to content

Commit 62b171f

Browse files
committed
UI Test: Support high dpi displays for UI testing
1 parent 60e0e2d commit 62b171f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Samples.UITest/UITest.Core/UITestBase.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Globalization;
77
using System.Reflection;
88
using System.Runtime.CompilerServices;
9+
using System.Runtime.InteropServices;
910
using Xunit.Abstractions;
1011

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

1819
static UITestBase()
1920
{
21+
NativeMethods.SetProcessDPIAware();
2022
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
2123

2224
Mouse.MovePixelsPerMillisecond = 2;
@@ -111,4 +113,11 @@ public void Dispose()
111113
if (File.Exists(file)) File.Delete(file);
112114
}
113115
}
116+
117+
118+
private static class NativeMethods
119+
{
120+
[DllImport("user32.dll", SetLastError = true)]
121+
public static extern bool SetProcessDPIAware();
122+
}
114123
}

0 commit comments

Comments
 (0)