2019-09-04 18:26:26 +02:00
|
|
|
#include "pch.h"
|
|
|
|
|
|
2020-02-10 14:59:51 +01:00
|
|
|
#include <filesystem>
|
|
|
|
|
|
2021-06-23 15:48:54 +03:00
|
|
|
#include <FancyZonesLib/util.h>
|
|
|
|
|
#include <FancyZonesLib/ZoneSet.h>
|
2021-07-07 13:18:52 +03:00
|
|
|
#include <FancyZonesLib/WorkArea.h>
|
2021-06-23 15:48:54 +03:00
|
|
|
#include <FancyZonesLib/FancyZones.h>
|
2022-01-27 15:21:15 +03:00
|
|
|
#include <FancyZonesLib/FancyZonesData/AppliedLayouts.h>
|
2022-01-24 14:54:17 +03:00
|
|
|
#include <FancyZonesLib/FancyZonesData/AppZoneHistory.h>
|
2021-06-23 15:48:54 +03:00
|
|
|
#include <FancyZonesLib/FancyZonesDataTypes.h>
|
|
|
|
|
#include <FancyZonesLib/JsonHelpers.h>
|
2021-07-07 13:18:52 +03:00
|
|
|
#include <FancyZonesLib/ZoneColors.h>
|
2019-12-17 11:21:46 +03:00
|
|
|
#include "Util.h"
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
#include <common/utils/process_path.h>
|
|
|
|
|
|
2019-09-04 18:26:26 +02:00
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
|
|
|
|
|
|
namespace FancyZonesUnitTests
|
|
|
|
|
{
|
2020-08-21 08:56:25 +03:00
|
|
|
const std::wstring m_deviceId = L"\\\\?\\DISPLAY#DELA026#5&10a58c63&0&UID16777488#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}";
|
|
|
|
|
const std::wstring m_virtualDesktopId = L"MyVirtualDesktopId";
|
|
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_CLASS (WorkAreaCreationUnitTests)
|
2020-02-10 14:59:51 +01:00
|
|
|
{
|
2021-09-23 00:39:48 +03:00
|
|
|
FancyZonesDataTypes::DeviceIdData m_parentUniqueId;
|
|
|
|
|
FancyZonesDataTypes::DeviceIdData m_uniqueId;
|
2019-12-10 17:17:40 -08:00
|
|
|
|
2020-02-10 14:59:51 +01:00
|
|
|
HINSTANCE m_hInst{};
|
|
|
|
|
HMONITOR m_monitor{};
|
2020-11-17 11:38:19 +03:00
|
|
|
MONITORINFOEX m_monitorInfo{};
|
|
|
|
|
GUID m_virtualDesktopGuid{};
|
2021-07-07 13:18:52 +03:00
|
|
|
ZoneColors m_zoneColors{};
|
|
|
|
|
OverlappingZonesAlgorithm m_overlappingAlgorithm = OverlappingZonesAlgorithm::Positional;
|
2021-12-20 17:50:51 +01:00
|
|
|
bool m_showZoneText = true;
|
2019-12-10 17:17:40 -08:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
void testWorkArea(winrt::com_ptr<IWorkArea> workArea)
|
2020-08-21 08:56:25 +03:00
|
|
|
{
|
|
|
|
|
const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom);
|
|
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
Assert::IsNotNull(workArea.get());
|
2021-09-23 00:39:48 +03:00
|
|
|
Assert::IsTrue(m_uniqueId == workArea->UniqueId());
|
2020-08-21 08:56:25 +03:00
|
|
|
}
|
|
|
|
|
|
2020-02-10 14:59:51 +01:00
|
|
|
TEST_METHOD_INITIALIZE(Init)
|
2022-01-27 15:21:15 +03:00
|
|
|
{
|
|
|
|
|
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2022-01-27 15:21:15 +03:00
|
|
|
m_monitor = MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
|
m_monitorInfo.cbSize = sizeof(m_monitorInfo);
|
|
|
|
|
Assert::AreNotEqual(0, GetMonitorInfoW(m_monitor, &m_monitorInfo));
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2022-01-27 15:21:15 +03:00
|
|
|
m_parentUniqueId.deviceName = L"DELA026#5&10a58c63&0&UID16777488";
|
|
|
|
|
m_parentUniqueId.width = m_monitorInfo.rcMonitor.right - m_monitorInfo.rcMonitor.left;
|
|
|
|
|
m_parentUniqueId.height = m_monitorInfo.rcMonitor.bottom - m_monitorInfo.rcMonitor.top;
|
|
|
|
|
CLSIDFromString(L"{61FA9FC0-26A6-4B37-A834-491C148DFC57}", &m_parentUniqueId.virtualDesktopId);
|
2021-09-23 00:39:48 +03:00
|
|
|
|
2022-01-27 15:21:15 +03:00
|
|
|
m_uniqueId.deviceName = L"DELA026#5&10a58c63&0&UID16777488";
|
|
|
|
|
m_uniqueId.width = m_monitorInfo.rcMonitor.right - m_monitorInfo.rcMonitor.left;
|
|
|
|
|
m_uniqueId.height = m_monitorInfo.rcMonitor.bottom - m_monitorInfo.rcMonitor.top;
|
|
|
|
|
CLSIDFromString(L"{39B25DD2-130D-4B5D-8851-4791D66B1539}", &m_uniqueId.virtualDesktopId);
|
|
|
|
|
|
|
|
|
|
auto guid = Helpers::StringToGuid(L"{39B25DD2-130D-4B5D-8851-4791D66B1539}");
|
|
|
|
|
Assert::IsTrue(guid.has_value());
|
|
|
|
|
m_virtualDesktopGuid = *guid;
|
|
|
|
|
|
|
|
|
|
m_zoneColors = ZoneColors{
|
|
|
|
|
.primaryColor = FancyZonesUtils::HexToRGB(L"#4287f5"),
|
|
|
|
|
.borderColor = FancyZonesUtils::HexToRGB(L"#FFFFFF"),
|
|
|
|
|
.highlightColor = FancyZonesUtils::HexToRGB(L"#42eff5"),
|
|
|
|
|
.highlightOpacity = 50,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AppZoneHistory::instance().LoadData();
|
|
|
|
|
AppliedLayouts::instance().LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD_CLEANUP(CleanUp)
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::remove(AppliedLayouts::AppliedLayoutsFileName());
|
|
|
|
|
std::filesystem::remove(AppZoneHistory::AppZoneHistoryFileName());
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_METHOD (CreateWorkArea)
|
2020-12-15 15:16:09 +03:00
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-07-07 13:18:52 +03:00
|
|
|
testWorkArea(workArea);
|
2020-09-04 16:37:06 +02:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
auto* zoneSet{ workArea->ZoneSet() };
|
|
|
|
|
Assert::IsNotNull(zoneSet);
|
|
|
|
|
Assert::AreEqual(static_cast<int>(zoneSet->LayoutType()), static_cast<int>(FancyZonesDataTypes::ZoneSetLayoutType::PriorityGrid));
|
|
|
|
|
Assert::AreEqual(zoneSet->GetZones().size(), static_cast<size_t>(3));
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_METHOD (CreateWorkAreaNoHinst)
|
2020-12-15 15:16:09 +03:00
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea({}, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-07-07 13:18:52 +03:00
|
|
|
testWorkArea(workArea);
|
2020-09-04 16:37:06 +02:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
auto* zoneSet{ workArea->ZoneSet() };
|
|
|
|
|
Assert::IsNotNull(zoneSet);
|
|
|
|
|
Assert::AreEqual(static_cast<int>(zoneSet->LayoutType()), static_cast<int>(FancyZonesDataTypes::ZoneSetLayoutType::PriorityGrid));
|
|
|
|
|
Assert::AreEqual(zoneSet->GetZones().size(), static_cast<size_t>(3));
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_METHOD (CreateWorkAreaNoHinstFlashZones)
|
2020-12-15 15:16:09 +03:00
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea({}, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-07-07 13:18:52 +03:00
|
|
|
testWorkArea(workArea);
|
2020-09-04 16:37:06 +02:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
auto* zoneSet{ workArea->ZoneSet() };
|
|
|
|
|
Assert::IsNotNull(zoneSet);
|
|
|
|
|
Assert::AreEqual(static_cast<int>(zoneSet->LayoutType()), static_cast<int>(FancyZonesDataTypes::ZoneSetLayoutType::PriorityGrid));
|
|
|
|
|
Assert::AreEqual(zoneSet->GetZones().size(), static_cast<size_t>(3));
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_METHOD (CreateWorkAreaNoMonitor)
|
2020-12-15 15:16:09 +03:00
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, {}, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-07-07 13:18:52 +03:00
|
|
|
testWorkArea(workArea);
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_METHOD (CreateWorkAreaNoDeviceId)
|
2020-12-15 15:16:09 +03:00
|
|
|
{
|
|
|
|
|
// Generate unique id without device id
|
2021-09-23 00:39:48 +03:00
|
|
|
FancyZonesDataTypes::DeviceIdData uniqueIdData;
|
|
|
|
|
uniqueIdData.virtualDesktopId = m_virtualDesktopGuid;
|
|
|
|
|
|
|
|
|
|
MONITORINFOEXW mi;
|
|
|
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
|
if (GetMonitorInfo(m_monitor, &mi))
|
|
|
|
|
{
|
|
|
|
|
FancyZonesUtils::Rect const monitorRect(mi.rcMonitor);
|
|
|
|
|
uniqueIdData.width = monitorRect.width();
|
|
|
|
|
uniqueIdData.height = monitorRect.height();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, uniqueIdData, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom);
|
2021-09-23 00:39:48 +03:00
|
|
|
const FancyZonesDataTypes::DeviceIdData expectedUniqueId{ L"FallbackDevice", m_monitorInfo.rcMonitor.right - m_monitorInfo.rcMonitor.left, m_monitorInfo.rcMonitor.bottom - m_monitorInfo.rcMonitor.top, m_virtualDesktopGuid };
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
Assert::IsNotNull(workArea.get());
|
2021-09-23 00:39:48 +03:00
|
|
|
Assert::IsTrue(expectedUniqueId == workArea->UniqueId());
|
2020-09-04 16:37:06 +02:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
auto* zoneSet{ workArea->ZoneSet() };
|
|
|
|
|
Assert::IsNotNull(zoneSet);
|
|
|
|
|
Assert::AreEqual(static_cast<int>(zoneSet->LayoutType()), static_cast<int>(FancyZonesDataTypes::ZoneSetLayoutType::PriorityGrid));
|
|
|
|
|
Assert::AreEqual(zoneSet->GetZones().size(), static_cast<size_t>(3));
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_METHOD (CreateWorkAreaNoDesktopId)
|
2020-12-15 15:16:09 +03:00
|
|
|
{
|
|
|
|
|
// Generate unique id without virtual desktop id
|
2021-09-23 00:39:48 +03:00
|
|
|
FancyZonesDataTypes::DeviceIdData uniqueId;
|
|
|
|
|
uniqueId.deviceName = FancyZonesUtils::TrimDeviceId(m_deviceId);
|
|
|
|
|
|
|
|
|
|
MONITORINFOEXW mi;
|
|
|
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
|
if (GetMonitorInfo(m_monitor, &mi))
|
|
|
|
|
{
|
|
|
|
|
FancyZonesUtils::Rect const monitorRect(mi.rcMonitor);
|
|
|
|
|
uniqueId.width = monitorRect.width();
|
|
|
|
|
uniqueId.height = monitorRect.height();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom);
|
2021-07-07 13:18:52 +03:00
|
|
|
Assert::IsNotNull(workArea.get());
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
auto* zoneSet{ workArea->ZoneSet() };
|
|
|
|
|
Assert::IsNotNull(zoneSet);
|
|
|
|
|
Assert::AreEqual(static_cast<int>(zoneSet->LayoutType()), static_cast<int>(FancyZonesDataTypes::ZoneSetLayoutType::PriorityGrid));
|
|
|
|
|
Assert::AreEqual(zoneSet->GetZones().size(), static_cast<size_t>(3));
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_METHOD (CreateWorkAreaClonedFromParent)
|
2021-01-27 21:33:52 +03:00
|
|
|
{
|
|
|
|
|
using namespace FancyZonesDataTypes;
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2022-01-27 15:21:15 +03:00
|
|
|
const ZoneSetLayoutType type = ZoneSetLayoutType::PriorityGrid;
|
|
|
|
|
const int spacing = 10;
|
|
|
|
|
const int zoneCount = 5;
|
|
|
|
|
const auto customSetGuid = Helpers::CreateGuidString();
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2022-01-27 15:21:15 +03:00
|
|
|
auto parentWorkArea = MakeWorkArea(m_hInst, m_monitor, m_parentUniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-07-07 13:18:52 +03:00
|
|
|
|
2022-01-27 15:21:15 +03:00
|
|
|
// newWorkArea = false - workArea won't be cloned from parent
|
|
|
|
|
auto actualWorkArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
|
|
|
|
|
|
|
|
|
Assert::IsNotNull(actualWorkArea->ZoneSet());
|
|
|
|
|
|
|
|
|
|
Assert::IsTrue(AppliedLayouts::instance().GetAppliedLayoutMap().contains(m_uniqueId));
|
|
|
|
|
auto currentDeviceInfo = AppliedLayouts::instance().GetAppliedLayoutMap().at(m_uniqueId);
|
|
|
|
|
// default values
|
|
|
|
|
Assert::AreEqual(true, currentDeviceInfo.showSpacing);
|
|
|
|
|
Assert::AreEqual(3, currentDeviceInfo.zoneCount);
|
|
|
|
|
Assert::AreEqual(16, currentDeviceInfo.spacing);
|
|
|
|
|
Assert::AreEqual(static_cast<int>(ZoneSetLayoutType::PriorityGrid), static_cast<int>(currentDeviceInfo.type));
|
|
|
|
|
}
|
2020-08-21 08:56:25 +03:00
|
|
|
};
|
2020-04-10 16:29:18 +02:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
TEST_CLASS (WorkAreaUnitTests)
|
2020-08-21 08:56:25 +03:00
|
|
|
{
|
2021-09-23 00:39:48 +03:00
|
|
|
FancyZonesDataTypes::DeviceIdData m_uniqueId;
|
2020-08-21 08:56:25 +03:00
|
|
|
|
|
|
|
|
HINSTANCE m_hInst{};
|
|
|
|
|
HMONITOR m_monitor{};
|
|
|
|
|
MONITORINFO m_monitorInfo{};
|
2021-07-07 13:18:52 +03:00
|
|
|
ZoneColors m_zoneColors{};
|
|
|
|
|
OverlappingZonesAlgorithm m_overlappingAlgorithm = OverlappingZonesAlgorithm::Positional;
|
2021-12-20 17:50:51 +01:00
|
|
|
bool m_showZoneText = true;
|
2020-08-21 08:56:25 +03:00
|
|
|
|
|
|
|
|
TEST_METHOD_INITIALIZE(Init)
|
2022-01-24 14:54:17 +03:00
|
|
|
{
|
|
|
|
|
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
|
|
|
|
|
|
|
|
|
m_monitor = MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
|
m_monitorInfo.cbSize = sizeof(m_monitorInfo);
|
|
|
|
|
Assert::AreNotEqual(0, GetMonitorInfoW(m_monitor, &m_monitorInfo));
|
|
|
|
|
|
|
|
|
|
m_uniqueId.deviceName = L"DELA026#5&10a58c63&0&UID16777488";
|
|
|
|
|
m_uniqueId.width = m_monitorInfo.rcMonitor.right - m_monitorInfo.rcMonitor.left;
|
|
|
|
|
m_uniqueId.height = m_monitorInfo.rcMonitor.bottom - m_monitorInfo.rcMonitor.top;
|
|
|
|
|
CLSIDFromString(L"{39B25DD2-130D-4B5D-8851-4791D66B1539}", &m_uniqueId.virtualDesktopId);
|
2021-09-23 00:39:48 +03:00
|
|
|
|
2022-01-24 14:54:17 +03:00
|
|
|
m_zoneColors = ZoneColors{
|
|
|
|
|
.primaryColor = FancyZonesUtils::HexToRGB(L"#4287f5"),
|
|
|
|
|
.borderColor = FancyZonesUtils::HexToRGB(L"#FFFFFF"),
|
|
|
|
|
.highlightColor = FancyZonesUtils::HexToRGB(L"#42eff5"),
|
|
|
|
|
.highlightOpacity = 50,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AppZoneHistory::instance().LoadData();
|
2022-01-27 15:21:15 +03:00
|
|
|
AppliedLayouts::instance().LoadData();
|
2022-01-24 14:54:17 +03:00
|
|
|
}
|
2021-07-07 13:18:52 +03:00
|
|
|
|
2022-01-24 14:54:17 +03:00
|
|
|
TEST_METHOD_CLEANUP(CleanUp)
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::remove(AppZoneHistory::AppZoneHistoryFileName());
|
2022-01-27 15:21:15 +03:00
|
|
|
std::filesystem::remove(AppliedLayouts::AppliedLayoutsFileName());
|
2022-01-24 14:54:17 +03:00
|
|
|
}
|
2020-08-21 08:56:25 +03:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
public:
|
|
|
|
|
TEST_METHOD (MoveSizeEnter)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeEnter(Mocks::Window());
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeEnterTwice)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveSizeEnter(Mocks::Window());
|
|
|
|
|
const auto actual = workArea->MoveSizeEnter(Mocks::Window());
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeUpdate)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeUpdate(POINT{ 0, 0 }, true, false);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeUpdatePointNegativeCoordinates)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeUpdate(POINT{ -10, -10 }, true, false);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeUpdatePointBigCoordinates)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeUpdate(POINT{ m_monitorInfo.rcMonitor.right + 1, m_monitorInfo.rcMonitor.bottom + 1 }, true, false);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeEnd)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-08-21 12:53:03 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto window = Mocks::Window();
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveSizeEnter(window);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeEnd(window, POINT{ 0, 0 });
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
const auto zoneSet = workArea->ZoneSet();
|
2020-12-15 15:16:09 +03:00
|
|
|
zoneSet->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
|
|
|
|
const auto actualZoneIndexSet = zoneSet->GetZoneIndexSetFromWindow(window);
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsFalse(std::vector<ZoneIndex>{} == actualZoneIndexSet);
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeEndWindowNotAdded)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto window = Mocks::Window();
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveSizeEnter(window);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeEnd(window, POINT{ -100, -100 });
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
const auto zoneSet = workArea->ZoneSet();
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto actualZoneIndexSet = zoneSet->GetZoneIndexSetFromWindow(window);
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsTrue(std::vector<ZoneIndex>{} == actualZoneIndexSet);
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeEndDifferentWindows)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto window = Mocks::Window();
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveSizeEnter(window);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = E_INVALIDARG;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeEnd(Mocks::Window(), POINT{ 0, 0 });
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeEndWindowNotSet)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = E_INVALIDARG;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeEnd(Mocks::Window(), POINT{ 0, 0 });
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeEndInvalidPoint)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto window = Mocks::Window();
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveSizeEnter(window);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto actual = workArea->MoveSizeEnd(window, POINT{ -1, -1 });
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
const auto zoneSet = workArea->ZoneSet();
|
2020-12-15 15:16:09 +03:00
|
|
|
zoneSet->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
|
|
|
|
const auto actualZoneIndex = zoneSet->GetZoneIndexSetFromWindow(window);
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsFalse(std::vector<ZoneIndex>{} == actualZoneIndex); // with invalid point zone remains the same
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveWindowIntoZoneByIndex)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveWindowIntoZoneByIndex(Mocks::Window(), 0);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-11-11 19:23:22 +02:00
|
|
|
const auto actual = workArea->ZoneSet();
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveWindowIntoZoneByDirectionAndIndex)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2022-01-24 14:54:17 +03:00
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
const auto& appHistoryArray = actualAppZoneHistory.begin()->second;
|
|
|
|
|
Assert::AreEqual((size_t)1, appHistoryArray.size());
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsTrue(std::vector<ZoneIndex>{ 0 } == appHistoryArray[0].zoneIndexSet);
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveWindowIntoZoneByDirectionManyTimes)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true);
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2022-01-24 14:54:17 +03:00
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
const auto& appHistoryArray = actualAppZoneHistory.begin()->second;
|
|
|
|
|
Assert::AreEqual((size_t)1, appHistoryArray.size());
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsTrue(std::vector<ZoneIndex>{ 2 } == appHistoryArray[0].zoneIndexSet);
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (SaveWindowProcessToZoneIndexNullptrWindow)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->SaveWindowProcessToZoneIndex(nullptr);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2022-01-24 14:54:17 +03:00
|
|
|
const auto actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::IsTrue(actualAppZoneHistory.empty());
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (SaveWindowProcessToZoneIndexNoWindowAdded)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
auto zone = MakeZone(RECT{ 0, 0, 100, 100 }, 1);
|
2021-11-11 19:23:22 +02:00
|
|
|
workArea->ZoneSet()->AddZone(zone);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->SaveWindowProcessToZoneIndex(window);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2022-01-24 14:54:17 +03:00
|
|
|
const auto actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::IsTrue(actualAppZoneHistory.empty());
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (SaveWindowProcessToZoneIndexNoWindowAddedWithFilledAppZoneHistory)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
const auto processPath = get_process_path(window);
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto deviceId = workArea->UniqueId();
|
2021-11-11 19:23:22 +02:00
|
|
|
const auto zoneSetId = workArea->ZoneSet()->Id();
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
// fill app zone history map
|
2022-01-24 14:54:17 +03:00
|
|
|
Assert::IsTrue(AppZoneHistory::instance().SetAppLastZones(window, deviceId, Helpers::GuidToString(zoneSetId), { 0 }));
|
|
|
|
|
Assert::AreEqual((size_t)1, AppZoneHistory::instance().GetFullAppZoneHistory().size());
|
|
|
|
|
const auto& appHistoryArray1 = AppZoneHistory::instance().GetFullAppZoneHistory().at(processPath);
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual((size_t)1, appHistoryArray1.size());
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsTrue(std::vector<ZoneIndex>{ 0 } == appHistoryArray1[0].zoneIndexSet);
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
// add zone without window
|
|
|
|
|
const auto zone = MakeZone(RECT{ 0, 0, 100, 100 }, 1);
|
2021-11-11 19:23:22 +02:00
|
|
|
workArea->ZoneSet()->AddZone(zone);
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->SaveWindowProcessToZoneIndex(window);
|
2022-01-24 14:54:17 +03:00
|
|
|
Assert::AreEqual((size_t)1, AppZoneHistory::instance().GetFullAppZoneHistory().size());
|
|
|
|
|
const auto& appHistoryArray2 = AppZoneHistory::instance().GetFullAppZoneHistory().at(processPath);
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual((size_t)1, appHistoryArray2.size());
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsTrue(std::vector<ZoneIndex>{ 0 } == appHistoryArray2[0].zoneIndexSet);
|
2020-12-15 15:16:09 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (SaveWindowProcessToZoneIndexWindowAdded)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
const auto processPath = get_process_path(window);
|
2021-07-07 13:18:52 +03:00
|
|
|
const auto deviceId = workArea->UniqueId();
|
2021-11-11 19:23:22 +02:00
|
|
|
const auto zoneSetId = workArea->ZoneSet()->Id();
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
auto zone = MakeZone(RECT{ 0, 0, 100, 100 }, 1);
|
2021-11-11 19:23:22 +02:00
|
|
|
workArea->ZoneSet()->AddZone(zone);
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveWindowIntoZoneByIndex(window, 0);
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
//fill app zone history map
|
2022-01-24 14:54:17 +03:00
|
|
|
Assert::IsTrue(AppZoneHistory::instance().SetAppLastZones(window, deviceId, Helpers::GuidToString(zoneSetId), { 2 }));
|
|
|
|
|
Assert::AreEqual((size_t)1, AppZoneHistory::instance().GetFullAppZoneHistory().size());
|
|
|
|
|
const auto& appHistoryArray = AppZoneHistory::instance().GetFullAppZoneHistory().at(processPath);
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual((size_t)1, appHistoryArray.size());
|
2021-08-11 17:05:03 +03:00
|
|
|
Assert::IsTrue(std::vector<ZoneIndex>{ 2 } == appHistoryArray[0].zoneIndexSet);
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->SaveWindowProcessToZoneIndex(window);
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2022-01-24 14:54:17 +03:00
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
2021-11-11 19:23:22 +02:00
|
|
|
const auto& expected = workArea->ZoneSet()->GetZoneIndexSetFromWindow(window);
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto& actual = appHistoryArray[0].zoneIndexSet;
|
|
|
|
|
Assert::IsTrue(expected == actual);
|
|
|
|
|
}
|
2020-04-14 10:40:30 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (WhenWindowIsNotResizablePlacingItIntoTheZoneShouldNotResizeIt)
|
|
|
|
|
{
|
2021-12-20 17:50:51 +01:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
|
2021-11-11 19:23:22 +02:00
|
|
|
Assert::IsNotNull(workArea->ZoneSet());
|
2020-04-14 10:40:30 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
auto window = Mocks::WindowCreate(m_hInst);
|
2020-04-14 10:40:30 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
int originalWidth = 450;
|
|
|
|
|
int originalHeight = 550;
|
2020-04-14 10:40:30 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
SetWindowPos(window, nullptr, 150, 150, originalWidth, originalHeight, SWP_SHOWWINDOW);
|
|
|
|
|
SetWindowLong(window, GWL_STYLE, GetWindowLong(window, GWL_STYLE) & ~WS_SIZEBOX);
|
2020-04-14 10:40:30 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
auto zone = MakeZone(RECT{ 50, 50, 300, 300 }, 1);
|
2021-11-11 19:23:22 +02:00
|
|
|
workArea->ZoneSet()->AddZone(zone);
|
2020-04-14 10:40:30 +02:00
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_LEFT, true);
|
2020-04-14 10:40:30 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
RECT inZoneRect;
|
|
|
|
|
GetWindowRect(window, &inZoneRect);
|
|
|
|
|
Assert::AreEqual(originalWidth, (int)inZoneRect.right - (int)inZoneRect.left);
|
|
|
|
|
Assert::AreEqual(originalHeight, (int)inZoneRect.bottom - (int)inZoneRect.top);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
};
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|