Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ private void RefreshCore()
{
_signaled = false;
_haveMainWindow = false;
_mainWindowTitle = null;
_haveResponding = false;
}

/// <summary>Additional logic invoked when the Process is closed.</summary>
Expand Down
36 changes: 36 additions & 0 deletions src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,42 @@ public void MainWindowHandle_GetWithGui_ShouldRefresh_Windows()
}
}

[Fact]
[OuterLoop]
[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Pops UI
[PlatformSpecific(TestPlatforms.Windows)]
public void MainWindowTitle_GetWithGui_ShouldRefresh_Windows()
{
const string ExePath = "notepad.exe";
Assert.True(IsProgramInstalled(ExePath));

using (Process process = Process.Start(ExePath))
{
try
{
Assert.Equal(string.Empty, process.MainWindowTitle);

for (int attempt = 0; attempt < 50; ++attempt)
{
process.Refresh();
if (process.MainWindowTitle != string.Empty)
{
break;
}

Thread.Sleep(100);
}

Assert.NotEqual(string.Empty, process.MainWindowTitle);
}
finally
{
process.Kill();
Assert.True(process.WaitForExit(WaitInMS));
}
}
}

[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void MainWindowTitle_NoWindow_ReturnsEmpty()
{
Expand Down