Files
PowerToys/src/modules/fancyzones/tests/UnitTests/Util.h
stefansjfw 0027a0af40 [FancyZones] Split and reorganize FancyZonesData and JSON Helpers (#5028)
* Rename JsonHelpers to FancyZonesData
Add new JsonHelpers.[h|cpp] files

* Introduce FancyZonesDataTypes

* Move first part of JSON related stuff to JsonHelpers files

* Small refactor

* Move all json related stuff to JsonHelpers

* Minor refactoring

* Fix formating

* Remove GetPersistFancyZonesJSONPath() and GetPersistAppZoneHistoryFilePath()
Remove GetActiveZoneSetTmpPath(), GetDeletedCustomZoneSetsTmpPath and GetAppliedZoneSetTmpPath()
Simplify tests

* Address PR comment - Rename FancyZonesDataNS to FancyZonesData

* Address PR comment - Rename local var

* Delete obsolete stuff

* Remove double and uneeded includes
Introduce const non-localizable string variables
Address all othe PR comments

* Add comments to explain hardcoded values

* Remove FancyZonesData namespace

* Introduce const non-localizable string variables in FancyZonesDataTypes

* Add comments to explain FancyZonesData maps

Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-07-22 10:39:13 +02:00

77 lines
2.1 KiB
C++

#pragma once
#include "lib/FancyZonesDataTypes.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(FancyZonesDataTypes::ZoneSetLayoutType t1, FancyZonesDataTypes::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();
}
template<>
std::wstring Microsoft::VisualStudio::CppUnitTestFramework::ToString(const std::vector<int>& vec)
{
std::wstring str = L"{";
for (size_t i = 0; i < vec.size(); i++)
{
str += std::to_wstring(vec[i]);
if (i != vec.size() - 1)
{
str += L",";
}
}
str += L"}";
return str;
}