-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't apply custom Firefox processing on startup (#958)
#957 introduced custom logic to handle Firefox starting while Whim was running. However, this logic is unnecessary if Firefox is started prior to Whim. This PR introduces `IWindowSector.StartupWindow` to store the windows which were open when Whim started. If the Firefox window is in this set, then the custom logic is not needed and all events are processed as normal.
- Loading branch information
Showing
8 changed files
with
161 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/Whim.Tests/Store/WindowSector/WindowPickersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using System.Linq; | ||
|
||
namespace Whim.Tests; | ||
|
||
public class WindowPickersTests | ||
{ | ||
[Theory, AutoSubstituteData] | ||
public void PickAllWindows(IRootSector rootSector, IWindow window1, IWindow window2, IWindow window3) | ||
{ | ||
// Given there are three windows | ||
rootSector.WindowSector.Windows.Returns( | ||
new Dictionary<HWND, IWindow> | ||
{ | ||
[(HWND)1] = window1, | ||
[(HWND)2] = window2, | ||
[(HWND)3] = window3, | ||
}.ToImmutableDictionary() | ||
); | ||
|
||
// When we get the windows | ||
var result = Pickers.PickAllWindows()(rootSector); | ||
|
||
// Then we get the windows | ||
Assert.Equal(3, result.Count()); | ||
} | ||
|
||
[Theory, AutoSubstituteData] | ||
public void PickWindowByHandle_Failure(IRootSector rootSector, IWindow window1, IWindow window2, IWindow window3) | ||
{ | ||
// Given there are three windows | ||
rootSector.WindowSector.Windows.Returns( | ||
new Dictionary<HWND, IWindow> | ||
{ | ||
[(HWND)1] = window1, | ||
[(HWND)2] = window2, | ||
[(HWND)3] = window3, | ||
}.ToImmutableDictionary() | ||
); | ||
|
||
HWND handle = (HWND)4; | ||
|
||
// When we get the window | ||
var result = Pickers.PickWindowByHandle(handle)(rootSector); | ||
|
||
// Then we get an exception | ||
Assert.False(result.IsSuccessful); | ||
} | ||
|
||
[Theory, AutoSubstituteData] | ||
public void PickWindowByHandle_Success(IRootSector rootSector, IWindow window1, IWindow window2, IWindow window3) | ||
{ | ||
// Given there are three windows | ||
rootSector.WindowSector.Windows.Returns( | ||
new Dictionary<HWND, IWindow> | ||
{ | ||
[(HWND)1] = window1, | ||
[(HWND)2] = window2, | ||
[(HWND)3] = window3, | ||
}.ToImmutableDictionary() | ||
); | ||
|
||
// When we get the window | ||
var result = Pickers.PickWindowByHandle((HWND)1)(rootSector); | ||
|
||
// Then we get the window | ||
Assert.True(result.IsSuccessful); | ||
Assert.Same(window1, result.Value); | ||
} | ||
|
||
[Theory, AutoSubstituteData] | ||
public void PickIsStartupWindow_Failure(IRootSector rootSector) | ||
{ | ||
// Given there are three startup windows | ||
rootSector.WindowSector.StartupWindows.Returns( | ||
new HashSet<HWND> { (HWND)1, (HWND)2, (HWND)3, }.ToImmutableHashSet() | ||
); | ||
|
||
HWND handle = (HWND)4; | ||
|
||
// When we get whether the window is a startup window | ||
var result = Pickers.PickIsStartupWindow(handle)(rootSector); | ||
|
||
// Then we get false | ||
Assert.False(result); | ||
} | ||
|
||
[Theory, AutoSubstituteData] | ||
public void PickIsStartupWindow_Success(IRootSector rootSector) | ||
{ | ||
// Given there are three startup windows | ||
rootSector.WindowSector.StartupWindows.Returns( | ||
new HashSet<HWND> { (HWND)1, (HWND)2, (HWND)3, }.ToImmutableHashSet() | ||
); | ||
|
||
// When we get whether the window is a startup window | ||
var result = Pickers.PickIsStartupWindow((HWND)1)(rootSector); | ||
|
||
// Then we get true | ||
Assert.True(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters