mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
* When moving window into zones using arrow keys, support multi-monitor scenario * Minor coding style adjustments * Split implementation into separate functions because of readability * Rename certain arguments * Modify unit tests after API changes * Address PR comments and add unit tests * Return true from MoveWindowIntoZoneByDirection only if window is successfully added to new zone * Improved monitor ordering (#1) * Implemented improved monitor ordering v1 * Fixed some embarrassing bugs, added some tests * Added one more test * Extracted a value to a variable * ASCII art in unit test comments describing monitor layouts * Removed empty line for consistency * Update comment to match the code * Refactored tests, added tests for X,Y offsets Co-authored-by: Ivan Stošić <ivan100sic@gmail.com>
60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "lib/JsonHelpers.h"
|
|
|
|
namespace CustomAssert
|
|
{
|
|
static void AreEqual(const RECT& r1, const RECT& r2)
|
|
{
|
|
const bool equal = ((r1.left == r2.left) && (r1.right == r2.right) && (r1.top == r2.top) && (r1.bottom == r2.bottom));
|
|
Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(equal);
|
|
}
|
|
|
|
static void AreEqual(GUID g1, GUID g2)
|
|
{
|
|
Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(g1 == g2);
|
|
}
|
|
|
|
static void AreEqual(JSONHelpers::ZoneSetLayoutType t1, JSONHelpers::ZoneSetLayoutType t2)
|
|
{
|
|
Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(t1 == t2);
|
|
}
|
|
|
|
static void AreEqual(const std::vector<std::pair<HMONITOR, RECT>>& a1, const std::vector<std::pair<HMONITOR, RECT>>& a2)
|
|
{
|
|
Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(a1.size() == a2.size());
|
|
for (size_t i = 0; i < a1.size(); i++)
|
|
{
|
|
Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(a1[i].first == a2[i].first);
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace Mocks
|
|
{
|
|
static HWND Window()
|
|
{
|
|
static UINT_PTR s_nextWindow = 0;
|
|
return reinterpret_cast<HWND>(++s_nextWindow);
|
|
}
|
|
|
|
static HMONITOR Monitor()
|
|
{
|
|
static UINT_PTR s_nextMonitor = 0;
|
|
return reinterpret_cast<HMONITOR>(++s_nextMonitor);
|
|
}
|
|
|
|
static HINSTANCE Instance()
|
|
{
|
|
static UINT_PTR s_nextInstance = 0;
|
|
return reinterpret_cast<HINSTANCE>(++s_nextInstance);
|
|
}
|
|
|
|
HWND WindowCreate(HINSTANCE hInst);
|
|
}
|
|
|
|
namespace Helpers
|
|
{
|
|
std::wstring GuidToString(const GUID& guid);
|
|
std::wstring CreateGuidString();
|
|
} |