-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved code shared with PowerToys MouseJump into "Common" folder for e…
…asier synching
- Loading branch information
1 parent
79835f9
commit a31135b
Showing
172 changed files
with
894 additions
and
615 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
69 changes: 69 additions & 0 deletions
69
src/FancyMouse.UnitTests/Common/Helpers/MouseHelperTests.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,69 @@ | ||
using FancyMouse.Common.Helpers; | ||
using FancyMouse.Common.Models.Drawing; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace FancyMouse.UnitTests.Common.Helpers; | ||
|
||
[TestClass] | ||
public static class MouseHelperTests | ||
{ | ||
[TestClass] | ||
public sealed class GetJumpLocationTests | ||
{ | ||
public sealed class TestCase | ||
{ | ||
public TestCase(PointInfo previewLocation, SizeInfo previewSize, RectangleInfo desktopBounds, PointInfo expectedResult) | ||
{ | ||
this.PreviewLocation = previewLocation; | ||
this.PreviewSize = previewSize; | ||
this.DesktopBounds = desktopBounds; | ||
this.ExpectedResult = expectedResult; | ||
} | ||
|
||
public PointInfo PreviewLocation { get; } | ||
|
||
public SizeInfo PreviewSize { get; } | ||
|
||
public RectangleInfo DesktopBounds { get; } | ||
|
||
public PointInfo ExpectedResult { get; } | ||
} | ||
|
||
public static IEnumerable<object[]> GetTestCases() | ||
{ | ||
// screen corners and midpoint with a zero origin | ||
yield return new object[] { new TestCase(new(0, 0), new(160, 120), new(0, 0, 1600, 1200), new(0, 0)) }; | ||
yield return new object[] { new TestCase(new(160, 0), new(160, 120), new(0, 0, 1600, 1200), new(1600, 0)) }; | ||
yield return new object[] { new TestCase(new(0, 120), new(160, 120), new(0, 0, 1600, 1200), new(0, 1200)) }; | ||
yield return new object[] { new TestCase(new(160, 120), new(160, 120), new(0, 0, 1600, 1200), new(1600, 1200)) }; | ||
yield return new object[] { new TestCase(new(80, 60), new(160, 120), new(0, 0, 1600, 1200), new(800, 600)) }; | ||
|
||
// screen corners and midpoint with a positive origin | ||
yield return new object[] { new TestCase(new(0, 0), new(160, 120), new(1000, 1000, 1600, 1200), new(1000, 1000)) }; | ||
yield return new object[] { new TestCase(new(160, 0), new(160, 120), new(1000, 1000, 1600, 1200), new(2600, 1000)) }; | ||
yield return new object[] { new TestCase(new(0, 120), new(160, 120), new(1000, 1000, 1600, 1200), new(1000, 2200)) }; | ||
yield return new object[] { new TestCase(new(160, 120), new(160, 120), new(1000, 1000, 1600, 1200), new(2600, 2200)) }; | ||
yield return new object[] { new TestCase(new(80, 60), new(160, 120), new(1000, 1000, 1600, 1200), new(1800, 1600)) }; | ||
|
||
// screen corners and midpoint with a negative origin | ||
yield return new object[] { new TestCase(new(0, 0), new(160, 120), new(-1000, -1000, 1600, 1200), new(-1000, -1000)) }; | ||
yield return new object[] { new TestCase(new(160, 0), new(160, 120), new(-1000, -1000, 1600, 1200), new(600, -1000)) }; | ||
yield return new object[] { new TestCase(new(0, 120), new(160, 120), new(-1000, -1000, 1600, 1200), new(-1000, 200)) }; | ||
yield return new object[] { new TestCase(new(160, 120), new(160, 120), new(-1000, -1000, 1600, 1200), new(600, 200)) }; | ||
yield return new object[] { new TestCase(new(80, 60), new(160, 120), new(-1000, -1000, 1600, 1200), new(-200, -400)) }; | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(GetTestCases), DynamicDataSourceType.Method)] | ||
public void RunTestCases(TestCase data) | ||
{ | ||
var actual = MouseHelper.GetJumpLocation( | ||
data.PreviewLocation, | ||
data.PreviewSize, | ||
data.DesktopBounds); | ||
var expected = data.ExpectedResult; | ||
Assert.AreEqual(expected.X, actual.X); | ||
Assert.AreEqual(expected.Y, actual.Y); | ||
} | ||
} | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions
4
...ests/Models/Drawing/RectangleInfoTests.cs → ...mmon/Models/Drawing/RectangleInfoTests.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
4 changes: 2 additions & 2 deletions
4
...UnitTests/Models/Drawing/SizeInfoTests.cs → ...ts/Common/Models/Drawing/SizeInfoTests.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
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.