Skip to content

Commit

Permalink
[FancyZones] Unit tests fix (#12018)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeraphimaZykova committed Jul 2, 2021
1 parent b42eb08 commit 71f2561
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/modules/fancyzones/FancyZonesLib/JsonHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ namespace NonLocalizable
const wchar_t MonitorId[] = L"monitor-id";
const wchar_t TopCoordinate[] = L"top-coordinate";
const wchar_t LeftCoordinate[] = L"left-coordinate";
const wchar_t Width[] = L"width";
const wchar_t Height[] = L"height";
const wchar_t IsSelected[] = L"is-selected";
const wchar_t ProcessId[] = L"process-id";
const wchar_t SpanZonesAcrossMonitors[] = L"span-zones-across-monitors";
Expand Down Expand Up @@ -514,8 +516,8 @@ namespace JSONHelpers
result.SetNamedValue(NonLocalizable::MonitorId, json::value(monitor.id));
result.SetNamedValue(NonLocalizable::TopCoordinate, json::value(monitor.top));
result.SetNamedValue(NonLocalizable::LeftCoordinate, json::value(monitor.left));
result.SetNamedValue(L"width", json::value(monitor.width));
result.SetNamedValue(L"height", json::value(monitor.height));
result.SetNamedValue(NonLocalizable::Width, json::value(monitor.width));
result.SetNamedValue(NonLocalizable::Height, json::value(monitor.height));
result.SetNamedValue(NonLocalizable::IsSelected, json::value(monitor.isSelected));

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2028,9 +2028,9 @@ namespace FancyZonesUnitTests
TEST_METHOD(MonitorToJson)
{
const auto deviceId = L"AOC2460#4&fe3a015&0&UID65793_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}";
MonitorInfo monitor{ 144, deviceId, -10, 0, true };
MonitorInfo monitor{ 144, deviceId, -10, 0, 1920, 1080, true };

const auto expectedStr = L"{\"dpi\": 144, \"monitor-id\": \"AOC2460#4&fe3a015&0&UID65793_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\", \"top-coordinate\": -10, \"left-coordinate\": 0, \"is-selected\": true}";
const auto expectedStr = L"{\"dpi\": 144, \"monitor-id\": \"AOC2460#4&fe3a015&0&UID65793_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\", \"top-coordinate\": -10, \"left-coordinate\": 0, \"width\": 1920, \"height\": 1080, \"is-selected\": true}";
const auto expected = json::JsonObject::Parse(expectedStr);

const auto actual = MonitorInfo::ToJson(monitor);
Expand All @@ -2040,14 +2040,14 @@ namespace FancyZonesUnitTests

TEST_METHOD(EditorArgsToJson)
{
MonitorInfo monitor1{ 144, L"AOC2460#4&fe3a015&0&UID65793_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}", -10, 0, true };
MonitorInfo monitor2{ 96, L"AOC2460#4&fe3a015&0&UID65793_1920_1080_{39B25DD2-130D-4B5D-8851-4791D66B1538}", 0, 1920, false };
MonitorInfo monitor1{ 144, L"AOC2460#4&fe3a015&0&UID65793_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}", -10, 0, 1920, 1080, true };
MonitorInfo monitor2{ 96, L"AOC2460#4&fe3a015&0&UID65793_1920_1080_{39B25DD2-130D-4B5D-8851-4791D66B1538}", 0, 1920, 1920, 1080, false };
EditorArgs args{
1, true, std::vector<MonitorInfo>{ monitor1, monitor2 }
};

const std::wstring expectedMonitor1 = L"{\"dpi\": 144, \"monitor-id\": \"AOC2460#4&fe3a015&0&UID65793_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\", \"top-coordinate\": -10, \"left-coordinate\": 0, \"is-selected\": true}";
const std::wstring expectedMonitor2 = L"{\"dpi\": 96, \"monitor-id\": \"AOC2460#4&fe3a015&0&UID65793_1920_1080_{39B25DD2-130D-4B5D-8851-4791D66B1538}\", \"top-coordinate\": 0, \"left-coordinate\": 1920, \"is-selected\": false}";
const std::wstring expectedMonitor1 = L"{\"dpi\": 144, \"monitor-id\": \"AOC2460#4&fe3a015&0&UID65793_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}\", \"top-coordinate\": -10, \"left-coordinate\": 0, \"width\": 1920, \"height\": 1080, \"is-selected\": true}";
const std::wstring expectedMonitor2 = L"{\"dpi\": 96, \"monitor-id\": \"AOC2460#4&fe3a015&0&UID65793_1920_1080_{39B25DD2-130D-4B5D-8851-4791D66B1538}\", \"top-coordinate\": 0, \"left-coordinate\": 1920, \"width\": 1920, \"height\": 1080, \"is-selected\": false}";
const std::wstring expectedStr = L"{\"process-id\": 1, \"span-zones-across-monitors\": true, \"monitors\": [" + expectedMonitor1 + L", " + expectedMonitor2 + L"]}";

const auto expected = json::JsonObject::Parse(expectedStr);
Expand Down

0 comments on commit 71f2561

Please sign in to comment.