diff --git a/src/WindowsMegaProxy/MainWindow.xaml.cs b/src/WindowsMegaProxy/MainWindow.xaml.cs index 9bf21e5..9030f53 100644 --- a/src/WindowsMegaProxy/MainWindow.xaml.cs +++ b/src/WindowsMegaProxy/MainWindow.xaml.cs @@ -941,7 +941,7 @@ private void SetConnected(bool value) } } - private bool CanPollConnections() => IsActive && IsVisible && WindowState != WindowState.Minimized && + private bool CanPollConnections() => IsVisible && WindowState != WindowState.Minimized && ((TabItem)Sections.Items[0]).IsSelected && connection.State == ConnectionState.Connected && engine?.Running == true; private DateTimeOffset nextConnectionsPoll; diff --git a/tests/WindowsMegaProxy.UiChecks/Program.cs b/tests/WindowsMegaProxy.UiChecks/Program.cs index ab15c76..c72c99e 100644 --- a/tests/WindowsMegaProxy.UiChecks/Program.cs +++ b/tests/WindowsMegaProxy.UiChecks/Program.cs @@ -409,9 +409,15 @@ private static void Main(string[] args) var otherWindow = new Window { Width = 200, Height = 100, Owner = window }; otherWindow.Show(); otherWindow.Activate(); Layout(otherWindow); Wait(window, (Task)refresh.Invoke(window, [false])!); - Assert(!window.IsActive && fixtureEngine.Polls == polls, "A visible unfocused window does not poll connections."); + Assert(!window.IsActive && fixtureEngine.Polls == polls + 1, "A visible unfocused window continues polling connections."); + polls = fixtureEngine.Polls; otherWindow.Close(); window.Activate(); Layout(window); + window.WindowState = WindowState.Minimized; + Wait(window, (Task)refresh.Invoke(window, [false])!); + Assert(fixtureEngine.Polls == polls, "A minimized window does not poll connections."); + window.WindowState = WindowState.Normal; Layout(window); + ((TabControl)window.FindName("Sections")).SelectedIndex = 3; Wait(window, (Task)refresh.Invoke(window, [false])!); Assert(fixtureEngine.Polls == polls, "An inactive connections page does not poll the core.");