2019-09-04 18:26:26 +02:00
|
|
|
#include "pch.h"
|
|
|
|
|
|
2020-02-10 14:59:51 +01:00
|
|
|
#include <filesystem>
|
|
|
|
|
|
2021-07-07 13:18:52 +03:00
|
|
|
#include <FancyZonesLib/WorkArea.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>
|
2022-10-25 17:55:36 +02:00
|
|
|
#include <FancyZonesLib/FancyZonesData/DefaultLayouts.h>
|
2022-10-31 13:44:25 +02:00
|
|
|
#include <FancyZonesLib/LayoutAssignedWindows.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
|
|
|
{
|
2022-07-01 17:29:02 +02:00
|
|
|
FancyZonesDataTypes::WorkAreaId m_uniqueId;
|
|
|
|
|
FancyZonesDataTypes::WorkAreaId m_emptyUniqueId;
|
2020-08-21 08:56:25 +03:00
|
|
|
|
2022-08-15 16:40:10 +03:00
|
|
|
HINSTANCE m_hInst{};
|
|
|
|
|
HMONITOR m_monitor{};
|
|
|
|
|
|
2020-02-10 14:59:51 +01:00
|
|
|
TEST_METHOD_INITIALIZE(Init)
|
2022-01-27 15:21:15 +03:00
|
|
|
{
|
2022-07-01 17:29:02 +02:00
|
|
|
m_uniqueId.monitorId.deviceId.id = L"DELA026";
|
|
|
|
|
m_uniqueId.monitorId.deviceId.instanceId = L"5&10a58c63&0&UID16777488";
|
|
|
|
|
m_uniqueId.monitorId.serialNumber = L"serial-number";
|
2022-08-15 16:40:10 +03:00
|
|
|
m_uniqueId.virtualDesktopId = FancyZonesUtils::GuidFromString(L"{39B25DD2-130D-4B5D-8851-4791D66B1539}").value();
|
2022-01-27 15:21:15 +03:00
|
|
|
|
|
|
|
|
AppZoneHistory::instance().LoadData();
|
|
|
|
|
AppliedLayouts::instance().LoadData();
|
2022-10-25 17:55:36 +02:00
|
|
|
DefaultLayouts::instance().LoadData();
|
2022-01-27 15:21:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD_CLEANUP(CleanUp)
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::remove(AppliedLayouts::AppliedLayoutsFileName());
|
|
|
|
|
std::filesystem::remove(AppZoneHistory::AppZoneHistoryFileName());
|
2022-10-25 17:55:36 +02:00
|
|
|
|
|
|
|
|
std::filesystem::remove(DefaultLayouts::DefaultLayoutsFileName());
|
2022-01-27 15:21:15 +03:00
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2022-06-14 16:45:45 +02:00
|
|
|
TEST_METHOD (CreateWorkArea)
|
|
|
|
|
{
|
2022-10-25 17:55:36 +02:00
|
|
|
const auto defaultLayout = DefaultLayouts::instance().GetDefaultLayout();
|
|
|
|
|
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea({}, Mocks::Monitor(), m_uniqueId, m_emptyUniqueId);
|
|
|
|
|
Assert::IsFalse(workArea == nullptr);
|
|
|
|
|
Assert::IsTrue(m_uniqueId == workArea->UniqueId());
|
2021-09-23 00:39:48 +03:00
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto& layout = workArea->GetLayout();
|
|
|
|
|
Assert::IsNotNull(layout.get());
|
|
|
|
|
Assert::IsNotNull(workArea->GetLayoutWindows().get());
|
|
|
|
|
Assert::AreEqual(static_cast<int>(defaultLayout.type), static_cast<int>(layout->Type()));
|
|
|
|
|
Assert::AreEqual(defaultLayout.zoneCount, static_cast<int>(layout->Zones().size()));
|
2022-06-14 16:45:45 +02:00
|
|
|
}
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2022-06-14 16:45:45 +02:00
|
|
|
TEST_METHOD (CreateCombinedWorkArea)
|
|
|
|
|
{
|
2022-10-25 17:55:36 +02:00
|
|
|
const auto defaultLayout = DefaultLayouts::instance().GetDefaultLayout();
|
|
|
|
|
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea({}, {}, m_uniqueId, m_emptyUniqueId);
|
|
|
|
|
Assert::IsFalse(workArea == nullptr);
|
|
|
|
|
Assert::IsTrue(m_uniqueId == workArea->UniqueId());
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto& layout = workArea->GetLayout();
|
|
|
|
|
Assert::IsNotNull(layout.get());
|
|
|
|
|
Assert::IsNotNull(workArea->GetLayoutWindows().get());
|
|
|
|
|
Assert::AreEqual(static_cast<int>(defaultLayout.type), static_cast<int>(layout->Type()));
|
|
|
|
|
Assert::AreEqual(defaultLayout.zoneCount, static_cast<int>(layout->Zones().size()));
|
2022-06-14 16:45:45 +02: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;
|
2022-08-15 16:40:10 +03:00
|
|
|
|
2022-07-01 17:29:02 +02:00
|
|
|
FancyZonesDataTypes::WorkAreaId parentUniqueId;
|
|
|
|
|
parentUniqueId.monitorId.deviceId.id = L"DELA026";
|
|
|
|
|
parentUniqueId.monitorId.deviceId.instanceId = L"5&10a58c63&0&UID16777488";
|
|
|
|
|
parentUniqueId.monitorId.serialNumber = L"serial-number";
|
2022-06-14 16:45:45 +02:00
|
|
|
parentUniqueId.virtualDesktopId = FancyZonesUtils::GuidFromString(L"{61FA9FC0-26A6-4B37-A834-491C148DFC57}").value();
|
|
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
LayoutData layout{
|
2022-06-14 16:45:45 +02:00
|
|
|
.uuid = FancyZonesUtils::GuidFromString(L"{61FA9FC0-26A6-4B37-A834-491C148DFC58}").value(),
|
|
|
|
|
.type = ZoneSetLayoutType::Rows,
|
|
|
|
|
.showSpacing = true,
|
|
|
|
|
.spacing = 10,
|
|
|
|
|
.zoneCount = 10,
|
|
|
|
|
.sensitivityRadius = 20,
|
|
|
|
|
};
|
2020-12-15 15:16:09 +03:00
|
|
|
|
2022-08-15 16:40:10 +03:00
|
|
|
auto parentWorkArea = MakeWorkArea(m_hInst, m_monitor, parentUniqueId, m_emptyUniqueId);
|
2022-06-14 16:45:45 +02:00
|
|
|
AppliedLayouts::instance().ApplyLayout(parentUniqueId, layout);
|
|
|
|
|
|
2022-08-15 16:40:10 +03:00
|
|
|
auto actualWorkArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, parentUniqueId);
|
2022-10-31 13:44:25 +02:00
|
|
|
Assert::IsNotNull(actualWorkArea->GetLayout().get());
|
|
|
|
|
Assert::IsNotNull(actualWorkArea->GetLayoutWindows().get());
|
2022-01-27 15:21:15 +03:00
|
|
|
|
|
|
|
|
Assert::IsTrue(AppliedLayouts::instance().GetAppliedLayoutMap().contains(m_uniqueId));
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto& actualLayout = AppliedLayouts::instance().GetAppliedLayoutMap().at(m_uniqueId);
|
2022-06-14 16:45:45 +02:00
|
|
|
|
|
|
|
|
Assert::AreEqual(static_cast<int>(layout.type), static_cast<int>(actualLayout.type));
|
|
|
|
|
Assert::AreEqual(FancyZonesUtils::GuidToString(layout.uuid).value(), FancyZonesUtils::GuidToString(actualLayout.uuid).value());
|
|
|
|
|
Assert::AreEqual(layout.sensitivityRadius, actualLayout.sensitivityRadius);
|
|
|
|
|
Assert::AreEqual(layout.showSpacing, actualLayout.showSpacing);
|
|
|
|
|
Assert::AreEqual(layout.spacing, actualLayout.spacing);
|
|
|
|
|
Assert::AreEqual(layout.zoneCount, actualLayout.zoneCount);
|
2022-01-27 15:21:15 +03:00
|
|
|
}
|
2022-10-25 17:55:36 +02:00
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWorkAreaWithCustomDefault)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
json::JsonObject root{};
|
|
|
|
|
json::JsonArray layoutsArray{};
|
|
|
|
|
json::JsonObject layout{};
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::DefaultLayoutsIds::UuidID, json::value(L"{ACE817FD-2C51-4E13-903A-84CAB86FD17C}"));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::DefaultLayoutsIds::TypeID, json::value(L"custom"));
|
|
|
|
|
json::JsonObject item{};
|
|
|
|
|
item.SetNamedValue(NonLocalizable::DefaultLayoutsIds::MonitorConfigurationTypeID, json::value(L"horizontal"));
|
|
|
|
|
item.SetNamedValue(NonLocalizable::DefaultLayoutsIds::LayoutID, layout);
|
|
|
|
|
layoutsArray.Append(item);
|
|
|
|
|
root.SetNamedValue(NonLocalizable::DefaultLayoutsIds::DefaultLayoutsArrayID, layoutsArray);
|
|
|
|
|
|
|
|
|
|
json::to_file(DefaultLayouts::DefaultLayoutsFileName(), root);
|
|
|
|
|
DefaultLayouts::instance().LoadData();
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
auto workArea = MakeWorkArea({}, Mocks::Monitor(), m_uniqueId, m_emptyUniqueId);
|
|
|
|
|
Assert::IsFalse(workArea == nullptr);
|
|
|
|
|
Assert::IsTrue(m_uniqueId == workArea->UniqueId());
|
|
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
Assert::IsNotNull(workArea->GetLayout().get());
|
|
|
|
|
|
|
|
|
|
const auto& actualLayout = workArea->GetLayout();
|
|
|
|
|
Assert::AreEqual(static_cast<int>(FancyZonesDataTypes::ZoneSetLayoutType::Custom), static_cast<int>(actualLayout->Type()));
|
|
|
|
|
Assert::IsTrue(FancyZonesUtils::GuidFromString(L"{ACE817FD-2C51-4E13-903A-84CAB86FD17C}").value() == actualLayout->Id());
|
2022-10-25 17:55:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWorkAreaWithTemplateDefault)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
json::JsonObject root{};
|
|
|
|
|
json::JsonArray layoutsArray{};
|
|
|
|
|
json::JsonObject layout{};
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::DefaultLayoutsIds::TypeID, json::value(L"grid"));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::DefaultLayoutsIds::ShowSpacingID, json::value(true));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::DefaultLayoutsIds::SpacingID, json::value(1));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::DefaultLayoutsIds::ZoneCountID, json::value(4));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::DefaultLayoutsIds::SensitivityRadiusID, json::value(30));
|
|
|
|
|
|
|
|
|
|
json::JsonObject item{};
|
|
|
|
|
item.SetNamedValue(NonLocalizable::DefaultLayoutsIds::MonitorConfigurationTypeID, json::value(L"horizontal"));
|
|
|
|
|
item.SetNamedValue(NonLocalizable::DefaultLayoutsIds::LayoutID, layout);
|
|
|
|
|
layoutsArray.Append(item);
|
|
|
|
|
root.SetNamedValue(NonLocalizable::DefaultLayoutsIds::DefaultLayoutsArrayID, layoutsArray);
|
|
|
|
|
|
|
|
|
|
json::to_file(DefaultLayouts::DefaultLayoutsFileName(), root);
|
|
|
|
|
DefaultLayouts::instance().LoadData();
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
auto workArea = MakeWorkArea({}, Mocks::Monitor(), m_uniqueId, m_emptyUniqueId);
|
|
|
|
|
Assert::IsFalse(workArea == nullptr);
|
|
|
|
|
Assert::IsTrue(m_uniqueId == workArea->UniqueId());
|
|
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
Assert::IsNotNull(workArea->GetLayout().get());
|
|
|
|
|
|
|
|
|
|
const auto& actualLayout = workArea->GetLayout();
|
|
|
|
|
Assert::AreEqual(static_cast<int>(FancyZonesDataTypes::ZoneSetLayoutType::Grid), static_cast<int>(actualLayout->Type()));
|
|
|
|
|
Assert::AreEqual(static_cast<size_t>(4), actualLayout->Zones().size());
|
|
|
|
|
Assert::IsTrue(GUID_NULL == actualLayout->Id());
|
2022-10-25 17:55:36 +02:00
|
|
|
}
|
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
|
|
|
{
|
2022-07-01 17:29:02 +02:00
|
|
|
FancyZonesDataTypes::WorkAreaId m_uniqueId;
|
|
|
|
|
FancyZonesDataTypes::WorkAreaId m_parentUniqueId; // default empty
|
2020-08-21 08:56:25 +03:00
|
|
|
|
|
|
|
|
HINSTANCE m_hInst{};
|
|
|
|
|
HMONITOR m_monitor{};
|
|
|
|
|
|
|
|
|
|
TEST_METHOD_INITIALIZE(Init)
|
2022-01-24 14:54:17 +03:00
|
|
|
{
|
2022-07-01 17:29:02 +02:00
|
|
|
m_uniqueId.monitorId.deviceId.id = L"DELA026";
|
|
|
|
|
m_uniqueId.monitorId.deviceId.instanceId = L"5&10a58c63&0&UID16777488";
|
|
|
|
|
m_uniqueId.monitorId.serialNumber = L"serial-number";
|
2022-08-15 16:40:10 +03:00
|
|
|
m_uniqueId.virtualDesktopId = FancyZonesUtils::GuidFromString(L"{39B25DD2-130D-4B5D-8851-4791D66B1539}").value();
|
2022-01-24 14:54:17 +03:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-06-14 16:45:45 +02:00
|
|
|
public:
|
2020-12-15 15:16:09 +03:00
|
|
|
TEST_METHOD (MoveSizeEnter)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2022-06-14 16:45:45 +02:00
|
|
|
const auto actual = workArea->MoveSizeUpdate(POINT{ LONG_MAX, LONG_MAX }, 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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
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);
|
2022-10-31 13:44:25 +02:00
|
|
|
workArea->MoveSizeUpdate({ 20, 20 }, true, true);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = S_OK;
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto actual = workArea->MoveSizeEnd(window);
|
2020-12-15 15:16:09 +03:00
|
|
|
Assert::AreEqual(expected, actual);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
const auto actualZoneIndexSet = layoutWindows->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 (MoveSizeEndDifferentWindows)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
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;
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto actual = workArea->MoveSizeEnd(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 (MoveSizeEndWindowNotSet)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
const auto expected = E_INVALIDARG;
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto actual = workArea->MoveSizeEnd(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 (SaveWindowProcessToZoneIndexNullptrWindow)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
auto window = Mocks::WindowCreate(m_hInst);
|
2022-10-31 13:44:25 +02:00
|
|
|
workArea->GetLayout()->Init(RECT{ 0, 0, 1920, 1080 }, Mocks::Monitor());
|
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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
2022-10-31 13:44:25 +02:00
|
|
|
|
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();
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto& layoutId = workArea->GetLayout()->Id();
|
2020-12-15 15:16:09 +03:00
|
|
|
|
|
|
|
|
// fill app zone history map
|
2022-10-31 13:44:25 +02:00
|
|
|
Assert::IsTrue(AppZoneHistory::instance().SetAppLastZones(window, deviceId, Helpers::GuidToString(layoutId), { 0 }));
|
2022-01-24 14:54:17 +03:00
|
|
|
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
|
2022-10-31 13:44:25 +02:00
|
|
|
workArea->GetLayout()->Init(RECT{ 0, 0, 1920, 1080 }, Mocks::Monitor());
|
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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
2022-10-31 13:44:25 +02:00
|
|
|
|
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();
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto& layoutId = workArea->GetLayout()->Id();
|
2020-12-15 15:16:09 +03:00
|
|
|
|
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-10-31 13:44:25 +02:00
|
|
|
Assert::IsTrue(AppZoneHistory::instance().SetAppLastZones(window, deviceId, Helpers::GuidToString(layoutId), { 2 }));
|
2022-01-24 14:54:17 +03:00
|
|
|
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());
|
2022-10-31 13:44:25 +02:00
|
|
|
const auto& expected = workArea->GetLayoutWindows()->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)
|
|
|
|
|
{
|
2022-06-14 16:45:45 +02:00
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, m_parentUniqueId);
|
2022-10-31 13:44:25 +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
|
|
|
|
2022-10-31 13:44:25 +02:00
|
|
|
workArea->GetLayout()->Init(RECT{ 0, 0, 1920, 1080 }, Mocks::Monitor());
|
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
|
|
|
};
|
2022-10-31 13:44:25 +02:00
|
|
|
|
|
|
|
|
TEST_CLASS (WorkAreaMoveWindowUnitTests)
|
|
|
|
|
{
|
|
|
|
|
const std::wstring m_virtualDesktopIdStr = L"{A998CA86-F08D-4BCA-AED8-77F5C8FC9925}";
|
|
|
|
|
const FancyZonesDataTypes::WorkAreaId m_uniqueId{
|
|
|
|
|
.monitorId = {
|
|
|
|
|
.monitor = Mocks::Monitor(),
|
|
|
|
|
.deviceId = {
|
|
|
|
|
.id = L"DELA026",
|
|
|
|
|
.instanceId = L"5&10a58c63&0&UID16777488",
|
|
|
|
|
.number = 1,
|
|
|
|
|
},
|
|
|
|
|
.serialNumber = L"serial-number"
|
|
|
|
|
},
|
|
|
|
|
.virtualDesktopId = FancyZonesUtils::GuidFromString(m_virtualDesktopIdStr).value()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FancyZonesDataTypes::WorkAreaId m_parentUniqueId; // default empty
|
|
|
|
|
|
|
|
|
|
HINSTANCE m_hInst{};
|
|
|
|
|
HMONITOR m_monitor{};
|
|
|
|
|
|
|
|
|
|
void PrepareEmptyLayout()
|
|
|
|
|
{
|
|
|
|
|
json::JsonObject root{};
|
|
|
|
|
json::JsonArray layoutsArray{};
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
json::JsonObject layout{};
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::UuidID, json::value(L"{ACE817FD-2C51-4E13-903A-84CAB86FD17C}"));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::TypeID, json::value(FancyZonesDataTypes::TypeToString(FancyZonesDataTypes::ZoneSetLayoutType::Blank)));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::ShowSpacingID, json::value(false));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::SpacingID, json::value(0));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::ZoneCountID, json::value(0));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::SensitivityRadiusID, json::value(0));
|
|
|
|
|
|
|
|
|
|
json::JsonObject workAreaId{};
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorID, json::value(m_uniqueId.monitorId.deviceId.id));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorInstanceID, json::value(m_uniqueId.monitorId.deviceId.instanceId));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorSerialNumberID, json::value(m_uniqueId.monitorId.serialNumber));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorNumberID, json::value(m_uniqueId.monitorId.deviceId.number));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::VirtualDesktopID, json::value(m_virtualDesktopIdStr));
|
|
|
|
|
|
|
|
|
|
json::JsonObject obj{};
|
|
|
|
|
obj.SetNamedValue(NonLocalizable::AppliedLayoutsIds::DeviceID, workAreaId);
|
|
|
|
|
obj.SetNamedValue(NonLocalizable::AppliedLayoutsIds::AppliedLayoutID, layout);
|
|
|
|
|
|
|
|
|
|
layoutsArray.Append(obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
root.SetNamedValue(NonLocalizable::AppliedLayoutsIds::AppliedLayoutsArrayID, layoutsArray);
|
|
|
|
|
json::to_file(AppliedLayouts::AppliedLayoutsFileName(), root);
|
|
|
|
|
|
|
|
|
|
AppliedLayouts::instance().LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PrepareGridLayout()
|
|
|
|
|
{
|
|
|
|
|
json::JsonObject root{};
|
|
|
|
|
json::JsonArray layoutsArray{};
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
json::JsonObject layout{};
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::UuidID, json::value(L"{ACE817FD-2C51-4E13-903A-84CAB86FD17C}"));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::TypeID, json::value(FancyZonesDataTypes::TypeToString(FancyZonesDataTypes::ZoneSetLayoutType::Grid)));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::ShowSpacingID, json::value(false));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::SpacingID, json::value(0));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::ZoneCountID, json::value(4));
|
|
|
|
|
layout.SetNamedValue(NonLocalizable::AppliedLayoutsIds::SensitivityRadiusID, json::value(20));
|
|
|
|
|
|
|
|
|
|
json::JsonObject workAreaId{};
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorID, json::value(m_uniqueId.monitorId.deviceId.id));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorInstanceID, json::value(m_uniqueId.monitorId.deviceId.instanceId));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorSerialNumberID, json::value(m_uniqueId.monitorId.serialNumber));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::MonitorNumberID, json::value(m_uniqueId.monitorId.deviceId.number));
|
|
|
|
|
workAreaId.SetNamedValue(NonLocalizable::AppliedLayoutsIds::VirtualDesktopID, json::value(m_virtualDesktopIdStr));
|
|
|
|
|
|
|
|
|
|
json::JsonObject obj{};
|
|
|
|
|
obj.SetNamedValue(NonLocalizable::AppliedLayoutsIds::DeviceID, workAreaId);
|
|
|
|
|
obj.SetNamedValue(NonLocalizable::AppliedLayoutsIds::AppliedLayoutID, layout);
|
|
|
|
|
|
|
|
|
|
layoutsArray.Append(obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
root.SetNamedValue(NonLocalizable::AppliedLayoutsIds::AppliedLayoutsArrayID, layoutsArray);
|
|
|
|
|
json::to_file(AppliedLayouts::AppliedLayoutsFileName(), root);
|
|
|
|
|
|
|
|
|
|
AppliedLayouts::instance().LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD_INITIALIZE(Init)
|
|
|
|
|
{
|
|
|
|
|
AppZoneHistory::instance().LoadData();
|
|
|
|
|
AppliedLayouts::instance().LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD_CLEANUP(CleanUp)
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::remove(AppZoneHistory::AppZoneHistoryFileName());
|
|
|
|
|
std::filesystem::remove(AppliedLayouts::AppliedLayoutsFileName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (EmptyZonesMoveLeftByIndex)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareEmptyLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_LEFT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)0, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{} == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (EmptyZonesRightByIndex)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareEmptyLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)0, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{} == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveLeftNonAppliedWindowByIndex)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_LEFT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 3 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveRightNonAppliedWindowByIndex)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowByIndex)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true);
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 1 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowByIndexCycle)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_LEFT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ (ZoneIndex)workArea->GetLayout()->Zones().size() - 1 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowByIndexNoCycle)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_LEFT, false);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (EmptyZonesMoveByPosition)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareEmptyLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_LEFT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)0, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{} == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveLeftNonAppliedWindowByPosition)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_LEFT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 1 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveRightNonAppliedWindowByPosition)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_RIGHT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowHorizontallyByPosition)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_RIGHT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 1 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowVerticallyByPosition)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_DOWN, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 2 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowByPositionHorizontallyCycle)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_LEFT, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 1 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowByPositionHorizontallyNoCycle)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_LEFT, false);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowByPositionVerticallyCycle)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_UP, true);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 2 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (MoveAppliedWindowByPositionVerticallyNoCycle)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndPosition(window, VK_UP, false);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (ExtendZoneHorizontally)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->ExtendWindowByDirectionAndPosition(window, VK_RIGHT);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0, 1 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (ExtendZoneVertically)
|
|
|
|
|
{
|
|
|
|
|
// prepare
|
|
|
|
|
PrepareGridLayout();
|
|
|
|
|
auto workArea = MakeWorkArea(m_hInst, m_uniqueId.monitorId.monitor, m_uniqueId, m_parentUniqueId);
|
|
|
|
|
const auto window = Mocks::WindowCreate(m_hInst);
|
|
|
|
|
workArea->MoveWindowIntoZoneByDirectionAndIndex(window, VK_RIGHT, true); // apply to 1st zone
|
|
|
|
|
|
|
|
|
|
// test
|
|
|
|
|
workArea->ExtendWindowByDirectionAndPosition(window, VK_DOWN);
|
|
|
|
|
|
|
|
|
|
const auto& actualAppZoneHistory = AppZoneHistory::instance().GetFullAppZoneHistory();
|
|
|
|
|
Assert::AreEqual((size_t)1, actualAppZoneHistory.size());
|
|
|
|
|
|
|
|
|
|
const auto& layoutWindows = workArea->GetLayoutWindows();
|
|
|
|
|
Assert::IsTrue(ZoneIndexSet{ 0, 2 } == layoutWindows->GetZoneIndexSetFromWindow(window));
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|