Skip to content

Commit 38d005a

Browse files
committed
Improve test duration by closing sub windows
Closing the web driver session with a subwindow open takes a long time. To improve test duration, close subwindows when closing the main window.
1 parent 5e9c1a3 commit 38d005a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/TestApplications/WpfApplication/MainWindow.xaml.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows;
1+
using System.ComponentModel;
2+
using System.Windows;
23
using System.Windows.Controls;
34
using System.Windows.Media;
45

@@ -9,6 +10,8 @@ namespace WpfApplication
910
/// </summary>
1011
public partial class MainWindow
1112
{
13+
private Window1 _subWindow;
14+
1215
public MainWindow()
1316
{
1417
InitializeComponent();
@@ -34,6 +37,12 @@ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
3437
base.OnRenderSizeChanged(sizeInfo);
3538
}
3639

40+
protected override void OnClosing(CancelEventArgs e)
41+
{
42+
_subWindow?.Close();
43+
base.OnClosing(e);
44+
}
45+
3746
private void OnShowLabel(object sender, RoutedEventArgs e)
3847
{
3948
MenuItem menuitem = sender as MenuItem;
@@ -68,8 +77,8 @@ private void OnDisableForm(object sender, RoutedEventArgs e)
6877

6978
private void MenuItem_Click(object sender, RoutedEventArgs e)
7079
{
71-
var window = new Window1();
72-
window.Show();
80+
_subWindow = new Window1();
81+
_subWindow.Show();
7382
}
7483

7584
private void LabelWithHover_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)

0 commit comments

Comments
 (0)