From 87fb6fc3d1f5073729717a6b16b6f12b79cea280 Mon Sep 17 00:00:00 2001 From: PrzemyslawTusinski <61138537+PrzemyslawTusinski@users.noreply.github.com> Date: Tue, 14 Apr 2020 10:40:30 +0200 Subject: [PATCH] Added unit test for non-resizable window placement (#2017) --- .../tests/UnitTests/ZoneWindow.Spec.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/modules/fancyzones/tests/UnitTests/ZoneWindow.Spec.cpp b/src/modules/fancyzones/tests/UnitTests/ZoneWindow.Spec.cpp index 3460894f32..96cdf6365b 100644 --- a/src/modules/fancyzones/tests/UnitTests/ZoneWindow.Spec.cpp +++ b/src/modules/fancyzones/tests/UnitTests/ZoneWindow.Spec.cpp @@ -711,5 +711,29 @@ namespace FancyZonesUnitTests const auto actual = m_fancyZonesData.GetAppZoneHistoryMap().at(processPath).zoneIndex; Assert::AreEqual(expected, actual); } + + TEST_METHOD (WhenWindowIsNotResizablePlacingItIntoTheZoneShouldNotResizeIt) + { + m_zoneWindow = InitZoneWindowWithActiveZoneSet(); + Assert::IsNotNull(m_zoneWindow->ActiveZoneSet()); + + auto window = Mocks::WindowCreate(m_hInst); + + int orginalWidth = 450; + int orginalHeight = 550; + + SetWindowPos(window, nullptr, 150, 150, orginalWidth, orginalHeight, SWP_SHOWWINDOW); + SetWindowLong(window, GWL_STYLE, GetWindowLong(window, GWL_STYLE) & ~WS_SIZEBOX); + + auto zone = MakeZone(RECT{ 50, 50, 300, 300 }); + m_zoneWindow->ActiveZoneSet()->AddZone(zone); + + m_zoneWindow->MoveWindowIntoZoneByDirection(window, VK_LEFT, true); + + RECT inZoneRect; + GetWindowRect(window, &inZoneRect); + Assert::AreEqual(orginalWidth, (int)inZoneRect.right - (int) inZoneRect.left); + Assert::AreEqual(orginalHeight, (int)inZoneRect.bottom - (int)inZoneRect.top); + } }; }