mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 07:47:54 +01:00
Fixing unit tests
This commit is contained in:
@@ -777,7 +777,7 @@ internal class WindowsDriver : ConsoleDriver {
|
|||||||
|
|
||||||
public WindowsConsole WinConsole { get; private set; }
|
public WindowsConsole WinConsole { get; private set; }
|
||||||
|
|
||||||
public override bool SupportsTrueColor => _isWindowsTerminal && Environment.OSVersion.Version.Build >= 14931;
|
public override bool SupportsTrueColor => _runningUnitTests || (_isWindowsTerminal && Environment.OSVersion.Version.Build >= 14931);
|
||||||
|
|
||||||
public override bool Force16Colors {
|
public override bool Force16Colors {
|
||||||
get => base.Force16Colors;
|
get => base.Force16Colors;
|
||||||
@@ -1452,7 +1452,11 @@ internal class WindowsDriver : ConsoleDriver {
|
|||||||
public override void Init (Action terminalResized)
|
public override void Init (Action terminalResized)
|
||||||
{
|
{
|
||||||
TerminalResized = terminalResized;
|
TerminalResized = terminalResized;
|
||||||
|
|
||||||
|
if (Environment.OSVersion.Platform == PlatformID.Unix) {
|
||||||
|
_runningUnitTests = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (WinConsole != null) {
|
if (WinConsole != null) {
|
||||||
var winSize = WinConsole.GetConsoleOutputWindow (out Point pos);
|
var winSize = WinConsole.GetConsoleOutputWindow (out Point pos);
|
||||||
@@ -1708,7 +1712,7 @@ internal class WindowsDriver : ConsoleDriver {
|
|||||||
WinConsole?.Cleanup ();
|
WinConsole?.Cleanup ();
|
||||||
WinConsole = null;
|
WinConsole = null;
|
||||||
|
|
||||||
if (_isWindowsTerminal) {
|
if (!_runningUnitTests && _isWindowsTerminal) {
|
||||||
// Disable alternative screen buffer.
|
// Disable alternative screen buffer.
|
||||||
Console.Out.Write (EscSeqUtils.CSI_RestoreAltBufferWithBackscroll);
|
Console.Out.Write (EscSeqUtils.CSI_RestoreAltBufferWithBackscroll);
|
||||||
}
|
}
|
||||||
@@ -1720,45 +1724,6 @@ internal class WindowsDriver : ConsoleDriver {
|
|||||||
throw new NotImplementedException ();
|
throw new NotImplementedException ();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
static string GetParentProcessName ()
|
|
||||||
{
|
|
||||||
#pragma warning disable CA1416 // Validate platform compatibility
|
|
||||||
var myId = Process.GetCurrentProcess ().Id;
|
|
||||||
var query = string.Format ($"SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {myId}");
|
|
||||||
var search = new ManagementObjectSearcher ("root\\CIMV2", query);
|
|
||||||
var queryObj = search.Get ().OfType<ManagementBaseObject> ().FirstOrDefault ();
|
|
||||||
if (queryObj == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var parentId = (uint)queryObj ["ParentProcessId"];
|
|
||||||
var parent = Process.GetProcessById ((int)parentId);
|
|
||||||
var prevParent = parent;
|
|
||||||
|
|
||||||
// Check if the parent is from other parent
|
|
||||||
while (queryObj != null) {
|
|
||||||
query = string.Format ($"SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {parentId}");
|
|
||||||
search = new ManagementObjectSearcher ("root\\CIMV2", query);
|
|
||||||
queryObj = search.Get ().OfType<ManagementBaseObject> ().FirstOrDefault ();
|
|
||||||
if (queryObj == null) {
|
|
||||||
return parent.ProcessName;
|
|
||||||
}
|
|
||||||
parentId = (uint)queryObj ["ParentProcessId"];
|
|
||||||
try {
|
|
||||||
parent = Process.GetProcessById ((int)parentId);
|
|
||||||
if (string.Equals (parent.ProcessName, "explorer", StringComparison.InvariantCultureIgnoreCase)) {
|
|
||||||
return prevParent.ProcessName;
|
|
||||||
}
|
|
||||||
prevParent = parent;
|
|
||||||
} catch (ArgumentException) {
|
|
||||||
|
|
||||||
return prevParent.ProcessName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent.ProcessName;
|
|
||||||
#pragma warning restore CA1416 // Validate platform compatibility
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -16,4 +16,5 @@
|
|||||||
"wslDistribution": "Debian"
|
"wslDistribution": "Debian"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user