Skip to content

Commit

Permalink
Add test for opening folder browser dialog
Browse files Browse the repository at this point in the history
In order to make writing tests morepleasant I add shortcuts for operations inside form
That allow me express tests better then just counting tabs and pressing enter.

This currently catches issue in dotnet#5319
  • Loading branch information
kant2002 committed Jul 24, 2021
1 parent f03f11f commit 0793bdc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ public static bool SendUpArrowKeyToProcess(Process process, bool switchToMainWin
return SendKeysToProcess(process, "{UP}");
}

/// <summary>
/// Presses Alt plus choosen letter on the given process if it can be made the foreground process
/// </summary>
/// <param name="process">The process to send the Alt and key to</param>
/// <param name="letter">Letter in addition to Alt to send to process.</param>
/// <returns>Whether or not the Up key was pressed on the process</returns>
/// <seealso cref="SendKeysToProcess(Process, string, bool)"/>
public static bool SendAltKeyToProcess(Process process, char letter, bool switchToMainWindow = true)
{
return SendKeysToProcess(process, "%{" + letter + "}", switchToMainWindow);
}

/// <summary>
/// Presses Tab any number of times on the given process if it can be made the foreground process
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,25 @@ public void WinformsControlsTest_FileDialogTest()
Assert.True(process.HasExited);
}

[Fact]
public void WinformsControlsTest_OpenFolderBrowserDialogTest()
{
Process process = TestHelpers.StartProcess(_exePath);
TestHelpers.SendTabKeysToProcess(process, MainFormControlsTabOrder.DialogsButton);
TestHelpers.SendEnterKeyToProcess(process);
TestHelpers.SendEnterKeyToProcess(process, switchToMainWindow: false);

TestHelpers.SendAltKeyToProcess(process, 'b', switchToMainWindow: false);
TestHelpers.SendAltKeyToProcess(process, 'o', switchToMainWindow: false);

Assert.False(process.HasExited);

process.Kill();
process.WaitForExit();

Assert.True(process.HasExited);
}

[Fact]
public void DataBindings_remove_should_unsubscribe_INotifyPropertyChanged_PropertyChanged_event()
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public Dialogs()
TypeDescriptor.AddProvider(new AssociatedMetadataTypeTypeDescriptionProvider(saveFileDialog1.GetType(), typeof(ExposedClientGuidMetadata)), saveFileDialog1);
TypeDescriptor.AddProvider(new AssociatedMetadataTypeTypeDescriptionProvider(folderBrowserDialog1.GetType(), typeof(ExposedClientGuidMetadata)), folderBrowserDialog1);

_btnOpen = new("Open dialog")
_btnOpen = new("&Open dialog")
{
Image = (System.Drawing.Bitmap?)(resources.GetObject("OpenDialog")),
Enabled = false
Enabled = false,
};

_btnOpen.Click += (s, e) =>
Expand Down

0 comments on commit 0793bdc

Please sign in to comment.