mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
[CI] FancyZones unit tests (#17910)
This commit is contained in:
@@ -9,19 +9,30 @@ class ZonesOverlay;
|
||||
class WorkArea
|
||||
{
|
||||
public:
|
||||
WorkArea(HINSTANCE hinstance);
|
||||
WorkArea(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& uniqueId);
|
||||
~WorkArea();
|
||||
|
||||
public:
|
||||
bool Init(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& uniqueId, const FancyZonesDataTypes::WorkAreaId& parentUniqueId);
|
||||
inline bool Init(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& parentUniqueId)
|
||||
{
|
||||
#ifndef UNIT_TESTS
|
||||
if (!InitWindow(hinstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
InitLayout(parentUniqueId);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool InitWorkAreaRect(HMONITOR monitor)
|
||||
{
|
||||
m_monitor = monitor;
|
||||
|
||||
#if defined(UNIT_TESTS)
|
||||
m_workAreaRect = FancyZonesUtils::Rect({ 0, 0, 1920, 1080 });
|
||||
return true;
|
||||
#endif
|
||||
#else
|
||||
|
||||
if (monitor)
|
||||
{
|
||||
@@ -38,6 +49,7 @@ public:
|
||||
{
|
||||
m_workAreaRect = FancyZonesUtils::GetAllMonitorsCombinedRect<&MONITORINFO::rcWork>();
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -72,7 +84,8 @@ protected:
|
||||
static LRESULT CALLBACK s_WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) noexcept;
|
||||
|
||||
private:
|
||||
void InitializeZoneSets(const FancyZonesDataTypes::WorkAreaId& parentUniqueId) noexcept;
|
||||
bool InitWindow(HINSTANCE hinstance) noexcept;
|
||||
void InitLayout(const FancyZonesDataTypes::WorkAreaId& parentUniqueId) noexcept;
|
||||
void CalculateZoneSet(OverlappingZonesAlgorithm overlappingAlgorithm) noexcept;
|
||||
void UpdateActiveZoneSet(_In_opt_ IZoneSet* zoneSet) noexcept;
|
||||
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept;
|
||||
@@ -81,8 +94,7 @@ private:
|
||||
|
||||
HMONITOR m_monitor{};
|
||||
FancyZonesUtils::Rect m_workAreaRect{};
|
||||
|
||||
FancyZonesDataTypes::WorkAreaId m_uniqueId;
|
||||
const FancyZonesDataTypes::WorkAreaId m_uniqueId;
|
||||
HWND m_window{}; // Hidden tool window used to represent current monitor desktop work area.
|
||||
HWND m_windowMoveSize{};
|
||||
winrt::com_ptr<IZoneSet> m_zoneSet;
|
||||
@@ -95,17 +107,18 @@ private:
|
||||
|
||||
inline std::shared_ptr<WorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::WorkAreaId& uniqueId, const FancyZonesDataTypes::WorkAreaId& parentUniqueId) noexcept
|
||||
{
|
||||
auto self = std::make_shared<WorkArea>(hinstance);
|
||||
auto self = std::make_shared<WorkArea>(hinstance, uniqueId);
|
||||
if (!self->InitWorkAreaRect(monitor))
|
||||
{
|
||||
self->LogInitializationError();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!self->Init(hinstance, uniqueId, parentUniqueId))
|
||||
if (!self->Init(hinstance, parentUniqueId))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user