mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[FancyZones] Configurable sensitivity radius (#6554)
* Add the setting for the Sensitivity Radius to JSON and the Editor Use the setting when determining Zones to highligh * Fix FanzyZones unit tests Add test for Json upgrade * Updated texts in FancyZone Editor More Text to Resources / Use Resources * Added constant for default of Sensitivity Radius * When installing from scratch of when a new device is added set the sensitivity radius to the default. Move all the constant values to a single namespace * restore correct formatting Co-authored-by: Remy Blok <remy.blok@prodware.nl>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Util.h"
|
||||
#include <common/settings_helpers.h>
|
||||
#include <modules\fancyzones\lib\JsonHelpers.h>
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
using namespace FancyZonesDataTypes;
|
||||
@@ -26,7 +27,7 @@ namespace FancyZonesUnitTests
|
||||
auto hres = CoCreateGuid(&m_id);
|
||||
Assert::AreEqual(S_OK, hres);
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, Mocks::Monitor());
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, Mocks::Monitor(), DefaultValues::SensitivityRadius);
|
||||
m_set = MakeZoneSet(m_config);
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ namespace FancyZonesUnitTests
|
||||
TEST_METHOD (TestCreateZoneSetGuidEmpty)
|
||||
{
|
||||
GUID zoneSetId{};
|
||||
ZoneSetConfig config(zoneSetId, m_layoutType, Mocks::Monitor());
|
||||
ZoneSetConfig config(zoneSetId, m_layoutType, Mocks::Monitor(), DefaultValues::SensitivityRadius);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
Assert::IsNotNull(&set);
|
||||
@@ -60,7 +61,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
TEST_METHOD (TestCreateZoneSetMonitorEmpty)
|
||||
{
|
||||
ZoneSetConfig config(m_id, m_layoutType, nullptr);
|
||||
ZoneSetConfig config(m_id, m_layoutType, nullptr, DefaultValues::SensitivityRadius);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
Assert::IsNotNull(&set);
|
||||
CustomAssert::AreEqual(set->Id(), m_id);
|
||||
@@ -69,7 +70,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
TEST_METHOD (TestCreateZoneSetKeyEmpty)
|
||||
{
|
||||
ZoneSetConfig config(m_id, m_layoutType, Mocks::Monitor());
|
||||
ZoneSetConfig config(m_id, m_layoutType, Mocks::Monitor(), DefaultValues::SensitivityRadius);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
Assert::IsNotNull(&set);
|
||||
CustomAssert::AreEqual(set->Id(), m_id);
|
||||
@@ -125,10 +126,10 @@ namespace FancyZonesUnitTests
|
||||
{
|
||||
for (size_t i = 0; i < 1024; i++)
|
||||
{
|
||||
int left = rand() % 10;
|
||||
int top = rand() % 10;
|
||||
int right = left + 1 + rand() % 100;
|
||||
int bottom = top + 1 + rand() % 100;
|
||||
int left = rand() % 10;
|
||||
int top = rand() % 10;
|
||||
int right = left + 1 + rand() % 100;
|
||||
int bottom = top + 1 + rand() % 100;
|
||||
winrt::com_ptr<IZone> zone = MakeZone({ left, top, right, bottom });
|
||||
Assert::IsNotNull(zone.get());
|
||||
m_set->AddZone(zone);
|
||||
@@ -283,7 +284,7 @@ namespace FancyZonesUnitTests
|
||||
compareZones(zone2, m_set->GetZones()[actual[1]]);
|
||||
}
|
||||
|
||||
TEST_METHOD(ZoneFromPointMultizoneQuad)
|
||||
TEST_METHOD (ZoneFromPointMultizoneQuad)
|
||||
{
|
||||
winrt::com_ptr<IZone> zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
m_set->AddZone(zone1);
|
||||
@@ -448,7 +449,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
m_set->AddZone(zone1);
|
||||
m_set->AddZone(zone2);
|
||||
|
||||
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
||||
|
||||
m_set->MoveWindowIntoZoneByPoint(window, Mocks::Window(), POINT{ 50, 50 });
|
||||
@@ -504,228 +505,228 @@ namespace FancyZonesUnitTests
|
||||
winrt::com_ptr<IZone> m_zone3;
|
||||
|
||||
TEST_METHOD_INITIALIZE(Initialize)
|
||||
{
|
||||
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor());
|
||||
m_set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
m_zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
m_zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
m_zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
m_set->AddZone(m_zone1);
|
||||
m_set->AddZone(m_zone2);
|
||||
m_set->AddZone(m_zone3);
|
||||
}
|
||||
|
||||
TEST_METHOD (EmptyZonesLeft)
|
||||
{
|
||||
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor());
|
||||
auto set = MakeZoneSet(config);
|
||||
|
||||
set->MoveWindowIntoZoneByDirectionAndIndex(Mocks::Window(), Mocks::Window(), VK_LEFT, true);
|
||||
}
|
||||
|
||||
TEST_METHOD (EmptyZonesRight)
|
||||
{
|
||||
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor());
|
||||
auto set = MakeZoneSet(config);
|
||||
|
||||
set->MoveWindowIntoZoneByDirectionAndIndex(Mocks::Window(), Mocks::Window(), VK_RIGHT, true);
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightNoZones)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftNoZones)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightTwice)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftTwice)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightMoreThanZonesCount)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
for (int i = 0; i <= m_set->GetZones().size(); i++)
|
||||
{
|
||||
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor(), DefaultValues::SensitivityRadius);
|
||||
m_set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
m_zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
m_zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
m_zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
m_set->AddZone(m_zone1);
|
||||
m_set->AddZone(m_zone2);
|
||||
m_set->AddZone(m_zone3);
|
||||
}
|
||||
|
||||
TEST_METHOD (EmptyZonesLeft)
|
||||
{
|
||||
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor(), DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(config);
|
||||
|
||||
set->MoveWindowIntoZoneByDirectionAndIndex(Mocks::Window(), Mocks::Window(), VK_LEFT, true);
|
||||
}
|
||||
|
||||
TEST_METHOD (EmptyZonesRight)
|
||||
{
|
||||
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor(), DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(config);
|
||||
|
||||
set->MoveWindowIntoZoneByDirectionAndIndex(Mocks::Window(), Mocks::Window(), VK_RIGHT, true);
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightNoZones)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftMoreThanZonesCount)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
for (int i = 0; i <= m_set->GetZones().size(); i++)
|
||||
TEST_METHOD (MoveLeftNoZones)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionRight)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightWithSameWindowAdded)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndexSet(window, Mocks::Window(), { 0, 1 });
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0, 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightWithDifferentWindowsAdded)
|
||||
{
|
||||
HWND window1 = Mocks::Window();
|
||||
HWND window2 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), { 0 });
|
||||
m_set->MoveWindowIntoZoneByIndex(window2, Mocks::Window(), { 1 });
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window1, Mocks::Window(), VK_RIGHT, true);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window1, Mocks::Window(), VK_RIGHT, true);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionLeft)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftWithSameWindowAdded)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndexSet(window, Mocks::Window(), {1, 2});
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 1, 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftWithDifferentWindowsAdded)
|
||||
{
|
||||
HWND window1 = Mocks::Window();
|
||||
HWND window2 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), 1);
|
||||
m_set->MoveWindowIntoZoneByIndex(window2, Mocks::Window(), 2);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionWrapAroundRight)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionWrapAroundLeft)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveSecondWindowIntoSameZone)
|
||||
{
|
||||
HWND window1 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), 0);
|
||||
|
||||
HWND window2 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_RIGHT, true);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightMoreThanZoneCountReturnsFalse)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
||||
for (size_t i = 0; i < m_set->GetZones().size() - 1; ++i)
|
||||
TEST_METHOD (MoveRightTwice)
|
||||
{
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, false);
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
bool moreZonesInLayout = m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, false);
|
||||
Assert::IsFalse(moreZonesInLayout);
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftMoreThanZoneCountReturnsFalse)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2);
|
||||
for (size_t i = 0; i < m_set->GetZones().size() - 1; ++i)
|
||||
TEST_METHOD (MoveLeftTwice)
|
||||
{
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, false);
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightMoreThanZonesCount)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
for (int i = 0; i <= m_set->GetZones().size(); i++)
|
||||
{
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
}
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftMoreThanZonesCount)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
for (int i = 0; i <= m_set->GetZones().size(); i++)
|
||||
{
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
}
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionRight)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightWithSameWindowAdded)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndexSet(window, Mocks::Window(), { 0, 1 });
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0, 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightWithDifferentWindowsAdded)
|
||||
{
|
||||
HWND window1 = Mocks::Window();
|
||||
HWND window2 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), { 0 });
|
||||
m_set->MoveWindowIntoZoneByIndex(window2, Mocks::Window(), { 1 });
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window1, Mocks::Window(), VK_RIGHT, true);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window1, Mocks::Window(), VK_RIGHT, true);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionLeft)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftWithSameWindowAdded)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndexSet(window, Mocks::Window(), { 1, 2 });
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 1, 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftWithDifferentWindowsAdded)
|
||||
{
|
||||
HWND window1 = Mocks::Window();
|
||||
HWND window2 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), 1);
|
||||
m_set->MoveWindowIntoZoneByIndex(window2, Mocks::Window(), 2);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 1 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionWrapAroundRight)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveWindowIntoZoneByDirectionWrapAroundLeft)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true);
|
||||
Assert::IsTrue(std::vector<size_t>{ 2 } == m_set->GetZoneIndexSetFromWindow(window));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveSecondWindowIntoSameZone)
|
||||
{
|
||||
HWND window1 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), 0);
|
||||
|
||||
HWND window2 = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_RIGHT, true);
|
||||
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window1));
|
||||
Assert::IsTrue(std::vector<size_t>{ 0 } == m_set->GetZoneIndexSetFromWindow(window2));
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveRightMoreThanZoneCountReturnsFalse)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0);
|
||||
for (size_t i = 0; i < m_set->GetZones().size() - 1; ++i)
|
||||
{
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, false);
|
||||
}
|
||||
bool moreZonesInLayout = m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, false);
|
||||
Assert::IsFalse(moreZonesInLayout);
|
||||
}
|
||||
|
||||
TEST_METHOD (MoveLeftMoreThanZoneCountReturnsFalse)
|
||||
{
|
||||
HWND window = Mocks::Window();
|
||||
m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2);
|
||||
for (size_t i = 0; i < m_set->GetZones().size() - 1; ++i)
|
||||
{
|
||||
m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, false);
|
||||
}
|
||||
bool moreZonesInLayout = m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, false);
|
||||
Assert::IsFalse(moreZonesInLayout);
|
||||
}
|
||||
bool moreZonesInLayout = m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, false);
|
||||
Assert::IsFalse(moreZonesInLayout);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CLASS (ZoneSetCalculateZonesUnitTests)
|
||||
@@ -759,7 +760,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
m_monitor = MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, m_monitor, DefaultValues::SensitivityRadius);
|
||||
m_set = MakeZoneSet(m_config);
|
||||
}
|
||||
|
||||
@@ -803,7 +804,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
|
||||
{
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
{
|
||||
@@ -821,7 +822,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
|
||||
{
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
MONITORINFO info{};
|
||||
@@ -837,7 +838,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
|
||||
{
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
{
|
||||
@@ -856,7 +857,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
|
||||
{
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -881,7 +882,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
|
||||
{
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -907,7 +908,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
|
||||
{
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -934,7 +935,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
|
||||
{
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -954,7 +955,7 @@ namespace FancyZonesUnitTests
|
||||
const int spacing = 10;
|
||||
const int zoneCount = 40; //editor limit
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, DefaultValues::SensitivityRadius);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
{
|
||||
@@ -977,7 +978,7 @@ namespace FancyZonesUnitTests
|
||||
std::filesystem::remove(m_path);
|
||||
}
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -995,7 +996,7 @@ namespace FancyZonesUnitTests
|
||||
Assert::IsTrue(std::filesystem::create_directories(m_path));
|
||||
Assert::IsTrue(std::filesystem::exists(m_path));
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -1016,7 +1017,7 @@ namespace FancyZonesUnitTests
|
||||
const int spacing = 10;
|
||||
const int zoneCount = static_cast<int>(info.zones.size());
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -1042,7 +1043,7 @@ namespace FancyZonesUnitTests
|
||||
const int spacing = 0;
|
||||
const int zoneCount = grid.rows() * grid.columns();
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
@@ -1077,7 +1078,7 @@ namespace FancyZonesUnitTests
|
||||
//test
|
||||
const int spacing = 10;
|
||||
const int zoneCount = static_cast<int>(info.zones.size());
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, DefaultValues::SensitivityRadius);
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
{
|
||||
auto set = MakeZoneSet(m_config);
|
||||
@@ -1117,7 +1118,7 @@ namespace FancyZonesUnitTests
|
||||
const int spacing = 10;
|
||||
const int zoneCount = grid.rows() * grid.columns();
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, DefaultValues::SensitivityRadius);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
{
|
||||
@@ -1141,7 +1142,7 @@ namespace FancyZonesUnitTests
|
||||
const int spacing = 0;
|
||||
const int zoneCount = grid.rows() * grid.columns();
|
||||
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
|
||||
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, DefaultValues::SensitivityRadius);
|
||||
auto set = MakeZoneSet(m_config);
|
||||
|
||||
for (const auto& monitorInfo : m_popularMonitors)
|
||||
|
||||
Reference in New Issue
Block a user