Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mouse Jump] - reduce winforms dependency, new thumbnail size settings, add shortcut keys - Ready For Review #25487

Merged
merged 13 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spell-check/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
^src/modules/fancyzones/lib/FancyZonesWinHookEventIDs\.h$
^src/modules/imageresizer/dll/ContextMenuHandler\.rgs$
^src/modules/imageresizer/dll/ImageResizerExt\.rgs$
^src/modules/MouseUtils/MouseJumpUI/NativeMethods/User32/UI/WindowsAndMessaging/User32.SYSTEM_METRICS_INDEX.cs$
^src/modules/powerrename/testapp/PowerRenameTest\.vcxproj\.filters$
^src/modules/previewpane/PreviewPaneUnitTests/HelperFiles/MarkdownWithHTMLImageTag\.txt$
^src/modules/previewpane/UnitTests-MarkdownPreviewHandler/HelperFiles/MarkdownWithHTMLImageTag.txt$
Expand Down
11 changes: 10 additions & 1 deletion .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ createdump
CREATESCHEDULEDTASK
CREATESTRUCT
CREATEWINDOWFAILED
CRECT
critsec
Crossdevice
CRSEL
Expand Down Expand Up @@ -512,6 +513,7 @@ dreamsofameaningfullife
drivedetectionwarning
dshow
DSTINVERT
DUMMYUNIONNAME
dutil
DVASPECT
DVASPECTINFO
Expand Down Expand Up @@ -1063,14 +1065,18 @@ LPBYTE
LPCITEMIDLIST
LPCMINVOKECOMMANDINFO
LPCREATESTRUCT
LPCRECT
LPCTSTR
LPCWSTR
lpdw
lpfn
lpmi
LPINPUT
LPMINMAXINFO
LPMONITORINFO
LPOSVERSIONINFOEXW
lprc
LPPOINT
LPRECT
LPSAFEARRAY
LPSTR
Expand Down Expand Up @@ -1180,6 +1186,7 @@ mockapi
MODECHANGE
modernwpf
MODESPRUNED
MONITORENUMPROC
MONITORINFO
MONITORINFOEX
MONITORINFOEXW
Expand Down Expand Up @@ -1333,7 +1340,7 @@ nugets
nullonfailure
numberbox
NUMLOCK
NUMPAD
numpad
nwc
Objbase
OBJID
Expand Down Expand Up @@ -1969,6 +1976,7 @@ TRAYMOUSEMESSAGE
triaging
TRK
trl
Tsd
TServer
TStr
TValue
Expand Down Expand Up @@ -2172,6 +2180,7 @@ winternl
WINTHRESHOLD
winui
winuiex
WINVER
winxamlmanager
wistd
withinrafael
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Helpers;
using MouseJumpUI.Models.Drawing;
using MouseJumpUI.Models.Layout;
using MouseJumpUI.Models.Screen;
using static MouseJumpUI.NativeMethods.Core;

namespace MouseJumpUI.UnitTests.Helpers;

[TestClass]
public static class DrawingHelperTests
{
[TestClass]
public class CalculateLayoutInfoTests
public sealed class CalculateLayoutInfoTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(LayoutConfig layoutConfig, LayoutInfo expectedResult)
{
Expand All @@ -40,13 +42,14 @@ public static IEnumerable<object[]> GetTestCases()
// | |
// +----------------+
var layoutConfig = new LayoutConfig(
virtualScreen: new(0, 0, 5120, 1440),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(0, 0, 5120, 1440),
screens: new List<ScreenInfo>
{
new(0, 0, 5120, 1440),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 5120, 1440), new(0, 0, 5120, 1440)),
},
activatedLocation: new(5120 / 2, 1440 / 2),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
Expand All @@ -58,7 +61,7 @@ public static IEnumerable<object[]> GetTestCases()
{
new(0, 0, 1590, 447.1875M),
},
activatedScreen: new(0, 0, 5120, 1440));
activatedScreenBounds: new(0, 0, 5120, 1440));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };

// primary monitor not topmost / leftmost - if there are screens
Expand All @@ -74,14 +77,15 @@ public static IEnumerable<object[]> GetTestCases()
// | |
// +----------------+
layoutConfig = new LayoutConfig(
virtualScreen: new(-1920, -472, 7040, 1912),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(-1920, -472, 7040, 1912),
screens: new List<ScreenInfo>
{
new(-1920, -472, 1920, 1080),
new(0, 0, 5120, 1440),
new ScreenInfo(HMONITOR.Null, false, new(-1920, -472, 1920, 1080), new(-1920, -472, 1920, 1080)),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 5120, 1440), new(0, 0, 5120, 1440)),
},
activatedLocation: new(-960, -236),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
Expand All @@ -99,7 +103,7 @@ public static IEnumerable<object[]> GetTestCases()
new(0, 0, 433.63636M, 243.92045M),
new(433.63636M, 106.602270M, 1156.36363M, 325.22727M),
},
activatedScreen: new(-1920, -472, 1920, 1080));
activatedScreenBounds: new(-1920, -472, 1920, 1080));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };

// check we handle rounding errors in scaling the preview form
Expand All @@ -115,14 +119,15 @@ public static IEnumerable<object[]> GetTestCases()
// | | 0 |
// +----------------+-------+
layoutConfig = new LayoutConfig(
virtualScreen: new(0, 0, 7168, 1440),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(0, 0, 7168, 1440),
screens: new List<ScreenInfo>
{
new(6144, 0, 1024, 768),
new(0, 0, 6144, 1440),
new ScreenInfo(HMONITOR.Null, false, new(6144, 0, 1024, 768), new(6144, 0, 1024, 768)),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 6144, 1440), new(0, 0, 6144, 1440)),
},
activatedLocation: new(6656, 384),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
Expand All @@ -135,7 +140,7 @@ public static IEnumerable<object[]> GetTestCases()
new(869.14285M, 0, 144.85714M, 108.642857M),
new(0, 0, 869.142857M, 203.705357M),
},
activatedScreen: new(6144, 0, 1024, 768));
activatedScreenBounds: new(6144, 0, 1024, 768));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };

// check we handle rounding errors in scaling the preview form
Expand All @@ -151,14 +156,15 @@ public static IEnumerable<object[]> GetTestCases()
// | | 0 |
// +----------------+-------+
layoutConfig = new LayoutConfig(
virtualScreen: new(0, 0, 7424, 1440),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(0, 0, 7424, 1440),
screens: new List<ScreenInfo>
{
new(6144, 0, 1280, 768),
new(0, 0, 6144, 1440),
new ScreenInfo(HMONITOR.Null, false, new(6144, 0, 1280, 768), new(6144, 0, 1280, 768)),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 6144, 1440), new(0, 0, 6144, 1440)),
},
activatedLocation: new(6784, 384),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
Expand All @@ -176,7 +182,7 @@ public static IEnumerable<object[]> GetTestCases()
new(1051.03448M, 0, 218.96551M, 131.37931M),
new(0, 0M, 1051.03448M, 246.33620M),
},
activatedScreen: new(6144, 0, 1280, 768));
activatedScreenBounds: new(6144, 0, 1280, 768));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };
}

Expand All @@ -191,7 +197,7 @@ public void RunTestCases(TestCase data)
// (int)1280.000000000000 -> 1280
// so we'll compare the raw values, *and* convert to an int-based
// Rectangle to compare rounded values
var actual = DrawingHelper.CalculateLayoutInfo(data.LayoutConfig);
var actual = LayoutHelper.CalculateLayoutInfo(data.LayoutConfig);
var expected = data.ExpectedResult;
Assert.AreEqual(expected.FormBounds.X, actual.FormBounds.X, 0.00001M, "FormBounds.X");
Assert.AreEqual(expected.FormBounds.Y, actual.FormBounds.Y, 0.00001M, "FormBounds.Y");
Expand All @@ -213,11 +219,11 @@ public void RunTestCases(TestCase data)
Assert.AreEqual(expected.ScreenBounds[i].ToRectangle(), actual.ScreenBounds[i].ToRectangle(), "ActivatedScreen.ToRectangle");
}

Assert.AreEqual(expected.ActivatedScreen.X, actual.ActivatedScreen.X, "ActivatedScreen.X");
Assert.AreEqual(expected.ActivatedScreen.Y, actual.ActivatedScreen.Y, "ActivatedScreen.Y");
Assert.AreEqual(expected.ActivatedScreen.Width, actual.ActivatedScreen.Width, "ActivatedScreen.Width");
Assert.AreEqual(expected.ActivatedScreen.Height, actual.ActivatedScreen.Height, "ActivatedScreen.Height");
Assert.AreEqual(expected.ActivatedScreen.ToRectangle(), actual.ActivatedScreen.ToRectangle(), "ActivatedScreen.ToRectangle");
Assert.AreEqual(expected.ActivatedScreenBounds.X, actual.ActivatedScreenBounds.X, "ActivatedScreen.X");
Assert.AreEqual(expected.ActivatedScreenBounds.Y, actual.ActivatedScreenBounds.Y, "ActivatedScreen.Y");
Assert.AreEqual(expected.ActivatedScreenBounds.Width, actual.ActivatedScreenBounds.Width, "ActivatedScreen.Width");
Assert.AreEqual(expected.ActivatedScreenBounds.Height, actual.ActivatedScreenBounds.Height, "ActivatedScreen.Height");
Assert.AreEqual(expected.ActivatedScreenBounds.ToRectangle(), actual.ActivatedScreenBounds.ToRectangle(), "ActivatedScreen.ToRectangle");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Helpers;
using MouseJumpUI.Models.Drawing;

namespace MouseJumpUI.UnitTests.Helpers;

[TestClass]
public static class MouseHelperTests
{
[TestClass]
public class GetJumpLocationTests
public sealed class GetJumpLocationTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(PointInfo previewLocation, SizeInfo previewSize, RectangleInfo desktopBounds, PointInfo expectedResult)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Models.Drawing;

namespace MouseJumpUI.UnitTests.Drawing;
namespace MouseJumpUI.UnitTests.Models.Drawing;

[TestClass]
public static class RectangleInfoTests
{
[TestClass]
public class CenterTests
public sealed class CenterTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(RectangleInfo rectangle, PointInfo point, RectangleInfo expectedResult)
{
Expand Down Expand Up @@ -63,9 +63,9 @@ public void RunTestCases(TestCase data)
}

[TestClass]
public class ClampTests
public sealed class ClampTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(RectangleInfo inner, RectangleInfo outer, RectangleInfo expectedResult)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Models.Drawing;

namespace MouseJumpUI.UnitTests.Drawing;

public sealed class SizeInfoTests
[TestClass]
public static class SizeInfoTests
{
[TestClass]
public class ScaleToFitTests
public sealed class ScaleToFitTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(SizeInfo obj, SizeInfo bounds, SizeInfo expectedResult)
{
Expand Down Expand Up @@ -58,9 +59,9 @@ public void RunTestCases(TestCase data)
}

[TestClass]
public class ScaleToFitRatioTests
public sealed class ScaleToFitRatioTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(SizeInfo obj, SizeInfo bounds, decimal expectedResult)
{
Expand Down
Loading