2020-02-10 14:59:51 +01:00
|
|
|
#include "pch.h"
|
|
|
|
|
#include <filesystem>
|
2020-03-17 00:29:13 +03:00
|
|
|
#include <fstream>
|
2020-02-10 14:59:51 +01:00
|
|
|
|
2021-06-23 15:48:54 +03:00
|
|
|
#include <FancyZonesLib/Settings.h>
|
|
|
|
|
#include <FancyZonesLib/FancyZones.h>
|
2020-12-15 15:16:09 +03:00
|
|
|
#include <common/SettingsAPI/settings_helpers.h>
|
2020-02-10 14:59:51 +01:00
|
|
|
|
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
|
|
|
|
|
|
namespace FancyZonesUnitTests
|
|
|
|
|
{
|
|
|
|
|
void compareHotkeyObjects(const PowerToysSettings::HotkeyObject& expected, const PowerToysSettings::HotkeyObject& actual)
|
|
|
|
|
{
|
|
|
|
|
Assert::AreEqual(expected.alt_pressed(), actual.alt_pressed());
|
|
|
|
|
Assert::AreEqual(expected.ctrl_pressed(), actual.ctrl_pressed());
|
|
|
|
|
Assert::AreEqual(expected.shift_pressed(), actual.shift_pressed());
|
|
|
|
|
Assert::AreEqual(expected.win_pressed(), actual.win_pressed());
|
|
|
|
|
|
|
|
|
|
//NOTE: key_from_code may create different values
|
|
|
|
|
//Assert::AreEqual(expected.get_key(), actual.get_key());
|
|
|
|
|
Assert::AreEqual(expected.get_code(), actual.get_code());
|
|
|
|
|
Assert::AreEqual(expected.get_modifiers(), actual.get_modifiers());
|
|
|
|
|
Assert::AreEqual(expected.get_modifiers_repeat(), actual.get_modifiers_repeat());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void compareSettings(const Settings& expected, const Settings& actual)
|
|
|
|
|
{
|
|
|
|
|
Assert::AreEqual(expected.shiftDrag, actual.shiftDrag);
|
2020-05-07 02:21:32 +03:00
|
|
|
Assert::AreEqual(expected.mouseSwitch, actual.mouseSwitch);
|
2020-02-10 14:59:51 +01:00
|
|
|
Assert::AreEqual(expected.displayChange_moveWindows, actual.displayChange_moveWindows);
|
|
|
|
|
Assert::AreEqual(expected.zoneSetChange_flashZones, actual.zoneSetChange_flashZones);
|
|
|
|
|
Assert::AreEqual(expected.zoneSetChange_moveWindows, actual.zoneSetChange_moveWindows);
|
|
|
|
|
Assert::AreEqual(expected.overrideSnapHotkeys, actual.overrideSnapHotkeys);
|
2020-05-01 16:17:16 +02:00
|
|
|
Assert::AreEqual(expected.moveWindowAcrossMonitors, actual.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
Assert::AreEqual(expected.moveWindowsBasedOnPosition, actual.moveWindowsBasedOnPosition);
|
2020-02-10 14:59:51 +01:00
|
|
|
Assert::AreEqual(expected.appLastZone_moveWindows, actual.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
Assert::AreEqual(expected.openWindowOnActiveMonitor, actual.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
Assert::AreEqual(expected.restoreSize, actual.restoreSize);
|
2020-02-10 14:59:51 +01:00
|
|
|
Assert::AreEqual(expected.use_cursorpos_editor_startupscreen, actual.use_cursorpos_editor_startupscreen);
|
2020-03-13 15:56:23 +01:00
|
|
|
Assert::AreEqual(expected.showZonesOnAllMonitors, actual.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
Assert::AreEqual(expected.spanZonesAcrossMonitors, actual.spanZonesAcrossMonitors);
|
2020-03-25 15:38:44 +01:00
|
|
|
Assert::AreEqual(expected.makeDraggedWindowTransparent, actual.makeDraggedWindowTransparent);
|
2021-11-03 17:11:42 +02:00
|
|
|
Assert::AreEqual(expected.windowSwitching, actual.windowSwitching);
|
2020-03-25 15:38:44 +01:00
|
|
|
Assert::AreEqual(expected.zoneColor.c_str(), actual.zoneColor.c_str());
|
|
|
|
|
Assert::AreEqual(expected.zoneBorderColor.c_str(), actual.zoneBorderColor.c_str());
|
2020-05-27 10:55:46 -04:00
|
|
|
Assert::AreEqual(expected.zoneHighlightColor.c_str(), actual.zoneHighlightColor.c_str());
|
2020-02-10 14:59:51 +01:00
|
|
|
Assert::AreEqual(expected.zoneHighlightOpacity, actual.zoneHighlightOpacity);
|
|
|
|
|
Assert::AreEqual(expected.excludedApps.c_str(), actual.excludedApps.c_str());
|
|
|
|
|
Assert::AreEqual(expected.excludedAppsArray.size(), actual.excludedAppsArray.size());
|
|
|
|
|
for (int i = 0; i < expected.excludedAppsArray.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
Assert::AreEqual(expected.excludedAppsArray[i].c_str(), actual.excludedAppsArray[i].c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compareHotkeyObjects(expected.editorHotkey, actual.editorHotkey);
|
2021-11-03 17:11:42 +02:00
|
|
|
compareHotkeyObjects(expected.nextTabHotkey, actual.nextTabHotkey);
|
|
|
|
|
compareHotkeyObjects(expected.prevTabHotkey, actual.prevTabHotkey);
|
2020-02-10 14:59:51 +01:00
|
|
|
}
|
|
|
|
|
|
2020-03-17 00:29:13 +03:00
|
|
|
TEST_CLASS (FancyZonesSettingsCreationUnitTest)
|
2020-02-10 14:59:51 +01:00
|
|
|
{
|
|
|
|
|
HINSTANCE m_hInst;
|
2020-05-27 21:09:18 +03:00
|
|
|
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
2020-10-19 16:07:02 -07:00
|
|
|
PCWSTR m_moduleKey = L"FancyZonesUnitTests";
|
2020-02-10 14:59:51 +01:00
|
|
|
std::wstring m_tmpName;
|
|
|
|
|
|
|
|
|
|
const Settings m_defaultSettings;
|
|
|
|
|
|
|
|
|
|
TEST_METHOD_INITIALIZE(Init)
|
2020-03-17 00:29:13 +03:00
|
|
|
{
|
|
|
|
|
m_hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
|
|
|
|
m_tmpName = PTSettingsHelper::get_module_save_folder_location(m_moduleName) + L"\\settings.json";
|
|
|
|
|
}
|
|
|
|
|
TEST_METHOD_CLEANUP(Cleanup)
|
|
|
|
|
{
|
2020-05-27 21:09:18 +03:00
|
|
|
std::filesystem::remove_all(PTSettingsHelper::get_module_save_folder_location(m_moduleName));
|
2020-03-17 00:29:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithHinstanceDefault)
|
|
|
|
|
{
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings({}, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(m_defaultSettings, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithHinstanceNullptr)
|
|
|
|
|
{
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(nullptr, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(m_defaultSettings, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithNameEmpty)
|
|
|
|
|
{
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, L"", m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(m_defaultSettings, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (Create)
|
|
|
|
|
{
|
|
|
|
|
//prepare data
|
2020-03-27 15:40:41 +03:00
|
|
|
const Settings expected;
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
2020-05-07 02:21:32 +03:00
|
|
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_flashZones", expected.zoneSetChange_flashZones);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_moveWindows", expected.zoneSetChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_overrideSnapHotkeys", expected.overrideSnapHotkeys);
|
2020-05-01 16:17:16 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowAcrossMonitors", expected.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowsBasedOnPosition", expected.moveWindowsBasedOnPosition);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_appLastZone_moveWindows", expected.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
values.add_property(L"fancyzones_openWindowOnActiveMonitor", expected.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
values.add_property(L"fancyzones_restoreSize", expected.restoreSize);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"use_cursorpos_editor_startupscreen", expected.use_cursorpos_editor_startupscreen);
|
|
|
|
|
values.add_property(L"fancyzones_show_on_all_monitors", expected.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
values.add_property(L"fancyzones_multi_monitor_mode", expected.spanZonesAcrossMonitors);
|
2020-03-25 15:38:44 +01:00
|
|
|
values.add_property(L"fancyzones_makeDraggedWindowTransparent", expected.makeDraggedWindowTransparent);
|
|
|
|
|
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
|
|
|
|
values.add_property(L"fancyzones_zoneBorderColor", expected.zoneBorderColor);
|
2020-05-27 10:55:46 -04:00
|
|
|
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_highlight_opacity", expected.zoneHighlightOpacity);
|
|
|
|
|
values.add_property(L"fancyzones_editor_hotkey", expected.editorHotkey.get_json());
|
2021-11-03 17:11:42 +02:00
|
|
|
values.add_property(L"fancyzones_windowSwitching", expected.windowSwitching);
|
|
|
|
|
values.add_property(L"fancyzones_nextTab_hotkey", expected.nextTabHotkey.get_json());
|
|
|
|
|
values.add_property(L"fancyzones_prevTab_hotkey", expected.prevTabHotkey.get_json());
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_excluded_apps", expected.excludedApps);
|
|
|
|
|
|
|
|
|
|
values.save_to_settings_file();
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(expected, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithMultipleApps)
|
|
|
|
|
{
|
|
|
|
|
//prepare data
|
|
|
|
|
const Settings expected{
|
|
|
|
|
.excludedApps = L"app\r\napp1\r\napp2\r\nanother app",
|
|
|
|
|
.excludedAppsArray = { L"APP", L"APP1", L"APP2", L"ANOTHER APP" },
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
2020-05-07 02:21:32 +03:00
|
|
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_flashZones", expected.zoneSetChange_flashZones);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_moveWindows", expected.zoneSetChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_overrideSnapHotkeys", expected.overrideSnapHotkeys);
|
2020-05-01 16:17:16 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowAcrossMonitors", expected.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowsBasedOnPosition", expected.moveWindowsBasedOnPosition);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_appLastZone_moveWindows", expected.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
values.add_property(L"fancyzones_openWindowOnActiveMonitor", expected.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
values.add_property(L"fancyzones_restoreSize", expected.restoreSize);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"use_cursorpos_editor_startupscreen", expected.use_cursorpos_editor_startupscreen);
|
|
|
|
|
values.add_property(L"fancyzones_show_on_all_monitors", expected.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
values.add_property(L"fancyzones_multi_monitor_mode", expected.spanZonesAcrossMonitors);
|
2020-03-25 15:38:44 +01:00
|
|
|
values.add_property(L"fancyzones_makeDraggedWindowTransparent", expected.makeDraggedWindowTransparent);
|
|
|
|
|
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
|
|
|
|
values.add_property(L"fancyzones_zoneBorderColor", expected.zoneBorderColor);
|
2020-05-27 10:55:46 -04:00
|
|
|
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_highlight_opacity", expected.zoneHighlightOpacity);
|
|
|
|
|
values.add_property(L"fancyzones_editor_hotkey", expected.editorHotkey.get_json());
|
2021-11-03 17:11:42 +02:00
|
|
|
values.add_property(L"fancyzones_windowSwitching", expected.windowSwitching);
|
|
|
|
|
values.add_property(L"fancyzones_nextTab_hotkey", expected.nextTabHotkey.get_json());
|
|
|
|
|
values.add_property(L"fancyzones_prevTab_hotkey", expected.prevTabHotkey.get_json());
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_excluded_apps", expected.excludedApps);
|
|
|
|
|
|
|
|
|
|
values.save_to_settings_file();
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(expected, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithBoolValuesMissed)
|
|
|
|
|
{
|
|
|
|
|
const Settings expected{
|
|
|
|
|
.shiftDrag = m_defaultSettings.shiftDrag,
|
2020-05-07 02:21:32 +03:00
|
|
|
.mouseSwitch = m_defaultSettings.mouseSwitch,
|
2020-03-17 00:29:13 +03:00
|
|
|
.displayChange_moveWindows = m_defaultSettings.displayChange_moveWindows,
|
|
|
|
|
.zoneSetChange_flashZones = m_defaultSettings.zoneSetChange_flashZones,
|
|
|
|
|
.zoneSetChange_moveWindows = m_defaultSettings.zoneSetChange_moveWindows,
|
|
|
|
|
.overrideSnapHotkeys = m_defaultSettings.overrideSnapHotkeys,
|
2020-05-01 16:17:16 +02:00
|
|
|
.moveWindowAcrossMonitors = m_defaultSettings.moveWindowAcrossMonitors,
|
2020-08-21 12:53:03 +02:00
|
|
|
.moveWindowsBasedOnPosition = m_defaultSettings.moveWindowsBasedOnPosition,
|
2020-03-17 00:29:13 +03:00
|
|
|
.appLastZone_moveWindows = m_defaultSettings.appLastZone_moveWindows,
|
2020-07-08 10:37:42 +02:00
|
|
|
.openWindowOnActiveMonitor = m_defaultSettings.openWindowOnActiveMonitor,
|
2020-07-01 15:36:05 +02:00
|
|
|
.restoreSize = m_defaultSettings.restoreSize,
|
2020-03-17 00:29:13 +03:00
|
|
|
.use_cursorpos_editor_startupscreen = m_defaultSettings.use_cursorpos_editor_startupscreen,
|
|
|
|
|
.showZonesOnAllMonitors = m_defaultSettings.showZonesOnAllMonitors,
|
2020-08-07 10:06:25 +02:00
|
|
|
.spanZonesAcrossMonitors = m_defaultSettings.spanZonesAcrossMonitors,
|
2020-03-25 15:38:44 +01:00
|
|
|
.makeDraggedWindowTransparent = m_defaultSettings.makeDraggedWindowTransparent,
|
|
|
|
|
.zoneColor = L"FAFAFA",
|
|
|
|
|
.zoneBorderColor = L"CCDDEE",
|
2020-05-27 10:55:46 -04:00
|
|
|
.zoneHighlightColor = L"#00FFD7",
|
2020-03-17 00:29:13 +03:00
|
|
|
.zoneHighlightOpacity = 45,
|
|
|
|
|
.editorHotkey = PowerToysSettings::HotkeyObject::from_settings(false, true, true, false, VK_OEM_3),
|
2021-11-03 17:11:42 +02:00
|
|
|
.nextTabHotkey = PowerToysSettings::HotkeyObject::from_settings(false, true, true, false, VK_NEXT),
|
|
|
|
|
.prevTabHotkey = PowerToysSettings::HotkeyObject::from_settings(false, true, true, false, VK_PRIOR),
|
2020-03-17 00:29:13 +03:00
|
|
|
.excludedApps = L"app",
|
|
|
|
|
.excludedAppsArray = { L"APP" },
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
2020-03-25 15:38:44 +01:00
|
|
|
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
|
|
|
|
values.add_property(L"fancyzones_zoneBorderColor", expected.zoneBorderColor);
|
2020-05-27 10:55:46 -04:00
|
|
|
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_highlight_opacity", expected.zoneHighlightOpacity);
|
|
|
|
|
values.add_property(L"fancyzones_editor_hotkey", expected.editorHotkey.get_json());
|
2021-11-03 17:11:42 +02:00
|
|
|
values.add_property(L"fancyzones_windowSwitching", expected.windowSwitching);
|
|
|
|
|
values.add_property(L"fancyzones_nextTab_hotkey", expected.nextTabHotkey.get_json());
|
|
|
|
|
values.add_property(L"fancyzones_prevTab_hotkey", expected.prevTabHotkey.get_json());
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_excluded_apps", expected.excludedApps);
|
|
|
|
|
|
|
|
|
|
values.save_to_settings_file();
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(expected, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateColorMissed)
|
|
|
|
|
{
|
|
|
|
|
//prepare data
|
2020-03-27 15:40:41 +03:00
|
|
|
const Settings expected;
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
2020-05-07 02:21:32 +03:00
|
|
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_flashZones", expected.zoneSetChange_flashZones);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_moveWindows", expected.zoneSetChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_overrideSnapHotkeys", expected.overrideSnapHotkeys);
|
2020-05-01 16:17:16 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowAcrossMonitors", expected.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowsBasedOnPosition", expected.moveWindowsBasedOnPosition);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_appLastZone_moveWindows", expected.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
values.add_property(L"fancyzones_openWindowOnActiveMonitor", expected.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
values.add_property(L"fancyzones_restoreSize", expected.restoreSize);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"use_cursorpos_editor_startupscreen", expected.use_cursorpos_editor_startupscreen);
|
|
|
|
|
values.add_property(L"fancyzones_show_on_all_monitors", expected.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
values.add_property(L"fancyzones_multi_monitor_mode", expected.spanZonesAcrossMonitors);
|
2020-03-25 15:38:44 +01:00
|
|
|
values.add_property(L"fancyzones_makeDraggedWindowTransparent", expected.makeDraggedWindowTransparent);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_highlight_opacity", expected.zoneHighlightOpacity);
|
|
|
|
|
values.add_property(L"fancyzones_editor_hotkey", expected.editorHotkey.get_json());
|
2021-11-03 17:11:42 +02:00
|
|
|
values.add_property(L"fancyzones_windowSwitching", expected.windowSwitching);
|
|
|
|
|
values.add_property(L"fancyzones_nextTab_hotkey", expected.nextTabHotkey.get_json());
|
|
|
|
|
values.add_property(L"fancyzones_prevTab_hotkey", expected.prevTabHotkey.get_json());
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_excluded_apps", expected.excludedApps);
|
|
|
|
|
|
|
|
|
|
values.save_to_settings_file();
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(expected, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateOpacityMissed)
|
|
|
|
|
{
|
|
|
|
|
//prepare data
|
2020-03-27 15:40:41 +03:00
|
|
|
const Settings expected;
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
2020-05-07 02:21:32 +03:00
|
|
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_flashZones", expected.zoneSetChange_flashZones);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_moveWindows", expected.zoneSetChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_overrideSnapHotkeys", expected.overrideSnapHotkeys);
|
2020-05-01 16:17:16 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowAcrossMonitors", expected.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowsBasedOnPosition", expected.moveWindowsBasedOnPosition);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_appLastZone_moveWindows", expected.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
values.add_property(L"fancyzones_openWindowOnActiveMonitor", expected.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
values.add_property(L"fancyzones_restoreSize", expected.restoreSize);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"use_cursorpos_editor_startupscreen", expected.use_cursorpos_editor_startupscreen);
|
|
|
|
|
values.add_property(L"fancyzones_show_on_all_monitors", expected.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
values.add_property(L"fancyzones_multi_monitor_mode", expected.spanZonesAcrossMonitors);
|
2020-03-25 15:38:44 +01:00
|
|
|
values.add_property(L"fancyzones_makeDraggedWindowTransparent", expected.makeDraggedWindowTransparent);
|
|
|
|
|
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
2020-05-27 10:55:46 -04:00
|
|
|
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_editor_hotkey", expected.editorHotkey.get_json());
|
2021-11-03 17:11:42 +02:00
|
|
|
values.add_property(L"fancyzones_windowSwitching", expected.windowSwitching);
|
|
|
|
|
values.add_property(L"fancyzones_nextTab_hotkey", expected.nextTabHotkey.get_json());
|
|
|
|
|
values.add_property(L"fancyzones_prevTab_hotkey", expected.prevTabHotkey.get_json());
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_excluded_apps", expected.excludedApps);
|
|
|
|
|
|
|
|
|
|
values.save_to_settings_file();
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(expected, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateHotkeyMissed)
|
|
|
|
|
{
|
|
|
|
|
//prepare data
|
2020-03-27 15:40:41 +03:00
|
|
|
const Settings expected;
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
2020-05-07 02:21:32 +03:00
|
|
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_flashZones", expected.zoneSetChange_flashZones);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_moveWindows", expected.zoneSetChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_overrideSnapHotkeys", expected.overrideSnapHotkeys);
|
2020-05-01 16:17:16 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowAcrossMonitors", expected.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowsBasedOnPosition", expected.moveWindowsBasedOnPosition);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_appLastZone_moveWindows", expected.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
values.add_property(L"fancyzones_openWindowOnActiveMonitor", expected.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
values.add_property(L"fancyzones_restoreSize", expected.restoreSize);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"use_cursorpos_editor_startupscreen", expected.use_cursorpos_editor_startupscreen);
|
|
|
|
|
values.add_property(L"fancyzones_show_on_all_monitors", expected.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
values.add_property(L"fancyzones_multi_monitor_mode", expected.spanZonesAcrossMonitors);
|
2020-03-25 15:38:44 +01:00
|
|
|
values.add_property(L"fancyzones_makeDraggedWindowTransparent", expected.makeDraggedWindowTransparent);
|
|
|
|
|
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
|
|
|
|
values.add_property(L"fancyzones_zoneBorderColor", expected.zoneBorderColor);
|
2020-05-27 10:55:46 -04:00
|
|
|
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_highlight_opacity", expected.zoneHighlightOpacity);
|
|
|
|
|
values.add_property(L"fancyzones_excluded_apps", expected.excludedApps);
|
|
|
|
|
|
|
|
|
|
values.save_to_settings_file();
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(expected, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateAppsMissed)
|
|
|
|
|
{
|
|
|
|
|
//prepare data
|
2020-03-27 15:40:41 +03:00
|
|
|
const Settings expected;
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
PowerToysSettings::PowerToyValues values(m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_shiftDrag", expected.shiftDrag);
|
2020-05-07 02:21:32 +03:00
|
|
|
values.add_property(L"fancyzones_mouseSwitch", expected.mouseSwitch);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_displayChange_moveWindows", expected.displayChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_flashZones", expected.zoneSetChange_flashZones);
|
|
|
|
|
values.add_property(L"fancyzones_zoneSetChange_moveWindows", expected.zoneSetChange_moveWindows);
|
|
|
|
|
values.add_property(L"fancyzones_overrideSnapHotkeys", expected.overrideSnapHotkeys);
|
2020-05-01 16:17:16 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowAcrossMonitors", expected.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
values.add_property(L"fancyzones_moveWindowsBasedOnPosition", expected.moveWindowsBasedOnPosition);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_appLastZone_moveWindows", expected.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
values.add_property(L"fancyzones_openWindowOnActiveMonitor", expected.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
values.add_property(L"fancyzones_restoreSize", expected.restoreSize);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"use_cursorpos_editor_startupscreen", expected.use_cursorpos_editor_startupscreen);
|
|
|
|
|
values.add_property(L"fancyzones_show_on_all_monitors", expected.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
values.add_property(L"fancyzones_multi_monitor_mode", expected.spanZonesAcrossMonitors);
|
2020-03-25 15:38:44 +01:00
|
|
|
values.add_property(L"fancyzones_makeDraggedWindowTransparent", expected.makeDraggedWindowTransparent);
|
|
|
|
|
values.add_property(L"fancyzones_zoneColor", expected.zoneColor);
|
|
|
|
|
values.add_property(L"fancyzones_zoneBorderColor", expected.zoneBorderColor);
|
2020-05-27 10:55:46 -04:00
|
|
|
values.add_property(L"fancyzones_zoneHighlightColor", expected.zoneHighlightColor);
|
2020-03-17 00:29:13 +03:00
|
|
|
values.add_property(L"fancyzones_highlight_opacity", expected.zoneHighlightOpacity);
|
|
|
|
|
values.add_property(L"fancyzones_editor_hotkey", expected.editorHotkey.get_json());
|
2021-11-03 17:11:42 +02:00
|
|
|
values.add_property(L"fancyzones_windowSwitching", expected.windowSwitching);
|
|
|
|
|
values.add_property(L"fancyzones_nextTab_hotkey", expected.nextTabHotkey.get_json());
|
|
|
|
|
values.add_property(L"fancyzones_prevTab_hotkey", expected.prevTabHotkey.get_json());
|
2020-03-17 00:29:13 +03:00
|
|
|
|
|
|
|
|
values.save_to_settings_file();
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(expected, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithEmptyJson)
|
|
|
|
|
{
|
|
|
|
|
json::to_file(m_tmpName, json::JsonObject());
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(m_defaultSettings, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithCorruptedJson)
|
|
|
|
|
{
|
|
|
|
|
std::wofstream{ m_tmpName.data(), std::ios::binary } << L"{ \"version\": \"1.0\", \"name\": \"";
|
|
|
|
|
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
|
|
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(m_defaultSettings, *actualSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD (CreateWithCyrillicSymbolsInJson)
|
|
|
|
|
{
|
|
|
|
|
std::wofstream{ m_tmpName.data(), std::ios::binary } << L"{ \"version\": \"1.0\", \"name\": \"ФансиЗонс\"}";
|
2020-10-19 16:07:02 -07:00
|
|
|
auto actual = MakeFancyZonesSettings(m_hInst, m_moduleName, m_moduleKey);
|
2020-03-17 00:29:13 +03:00
|
|
|
Assert::IsTrue(actual != nullptr);
|
|
|
|
|
|
|
|
|
|
auto actualSettings = actual->GetSettings();
|
|
|
|
|
compareSettings(m_defaultSettings, *actualSettings);
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
};
|
|
|
|
|
|
2020-03-17 00:29:13 +03:00
|
|
|
TEST_CLASS (FancyZonesSettingsUnitTests)
|
2020-02-10 14:59:51 +01:00
|
|
|
{
|
|
|
|
|
winrt::com_ptr<IFancyZonesSettings> m_settings = nullptr;
|
2020-05-27 21:09:18 +03:00
|
|
|
PCWSTR m_moduleName = L"FancyZonesUnitTests";
|
2020-10-19 16:07:02 -07:00
|
|
|
PCWSTR m_moduleKey = L"FancyZonesUnitTests";
|
2020-02-10 14:59:51 +01:00
|
|
|
|
|
|
|
|
std::wstring serializedPowerToySettings(const Settings& settings)
|
|
|
|
|
{
|
|
|
|
|
PowerToysSettings::Settings ptSettings(HINSTANCE{}, m_moduleName);
|
|
|
|
|
ptSettings.set_description(IDS_SETTING_DESCRIPTION);
|
|
|
|
|
ptSettings.set_icon_key(L"pt-fancy-zones");
|
2020-06-11 10:16:39 -07:00
|
|
|
ptSettings.set_overview_link(L"https://aka.ms/PowerToysOverview_FancyZones");
|
2020-02-10 14:59:51 +01:00
|
|
|
ptSettings.set_video_link(L"https://youtu.be/rTtGzZYAXgY");
|
|
|
|
|
|
|
|
|
|
ptSettings.add_custom_action(
|
|
|
|
|
L"ToggledFZEditor", // action name.
|
|
|
|
|
IDS_SETTING_LAUNCH_EDITOR_LABEL,
|
|
|
|
|
IDS_SETTING_LAUNCH_EDITOR_BUTTON,
|
|
|
|
|
IDS_SETTING_LAUNCH_EDITOR_DESCRIPTION);
|
|
|
|
|
ptSettings.add_hotkey(L"fancyzones_editor_hotkey", IDS_SETTING_LAUNCH_EDITOR_HOTKEY_LABEL, settings.editorHotkey);
|
2021-11-03 17:11:42 +02:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_windowSwitching", IDS_SETTING_WINDOW_SWITCHING_TOGGLE_LABEL, settings.windowSwitching);
|
|
|
|
|
ptSettings.add_hotkey(L"fancyzones_nextTab_hotkey", IDS_SETTING_NEXT_TAB_HOTKEY_LABEL, settings.nextTabHotkey);
|
|
|
|
|
ptSettings.add_hotkey(L"fancyzones_prevTab_hotkey", IDS_SETTING_PREV_TAB_HOTKEY_LABEL, settings.prevTabHotkey);
|
2020-05-26 14:12:20 -04:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_shiftDrag", IDS_SETTING_DESCRIPTION_SHIFTDRAG, settings.shiftDrag);
|
|
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_mouseSwitch", IDS_SETTING_DESCRIPTION_MOUSESWITCH, settings.mouseSwitch);
|
|
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_overrideSnapHotkeys", IDS_SETTING_DESCRIPTION_OVERRIDE_SNAP_HOTKEYS, settings.overrideSnapHotkeys);
|
|
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_moveWindowAcrossMonitors", IDS_SETTING_DESCRIPTION_MOVE_WINDOW_ACROSS_MONITORS, settings.moveWindowAcrossMonitors);
|
2020-08-21 12:53:03 +02:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_moveWindowsBasedOnPosition", IDS_SETTING_DESCRIPTION_MOVE_WINDOWS_BASED_ON_POSITION, settings.moveWindowsBasedOnPosition);
|
2020-05-26 14:12:20 -04:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_zoneSetChange_flashZones", IDS_SETTING_DESCRIPTION_ZONESETCHANGE_FLASHZONES, settings.zoneSetChange_flashZones);
|
|
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_displayChange_moveWindows", IDS_SETTING_DESCRIPTION_DISPLAYCHANGE_MOVEWINDOWS, settings.displayChange_moveWindows);
|
|
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_zoneSetChange_moveWindows", IDS_SETTING_DESCRIPTION_ZONESETCHANGE_MOVEWINDOWS, settings.zoneSetChange_moveWindows);
|
|
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_appLastZone_moveWindows", IDS_SETTING_DESCRIPTION_APPLASTZONE_MOVEWINDOWS, settings.appLastZone_moveWindows);
|
2020-07-08 10:37:42 +02:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_openWindowOnActiveMonitor", IDS_SETTING_DESCRIPTION_OPEN_WINDOW_ON_ACTIVE_MONITOR, settings.openWindowOnActiveMonitor);
|
2020-07-01 15:36:05 +02:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_restoreSize", IDS_SETTING_DESCRIPTION_RESTORESIZE, settings.restoreSize);
|
2020-05-26 14:12:20 -04:00
|
|
|
ptSettings.add_bool_toggle(L"use_cursorpos_editor_startupscreen", IDS_SETTING_DESCRIPTION_USE_CURSORPOS_EDITOR_STARTUPSCREEN, settings.use_cursorpos_editor_startupscreen);
|
|
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_show_on_all_monitors", IDS_SETTING_DESCRIPTION_SHOW_FANCY_ZONES_ON_ALL_MONITORS, settings.showZonesOnAllMonitors);
|
2020-08-07 10:06:25 +02:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_multi_monitor_mode", IDS_SETTING_DESCRIPTION_SPAN_ZONES_ACROSS_MONITORS, settings.spanZonesAcrossMonitors);
|
2020-05-26 14:12:20 -04:00
|
|
|
ptSettings.add_bool_toggle(L"fancyzones_makeDraggedWindowTransparent", IDS_SETTING_DESCRIPTION_MAKE_DRAGGED_WINDOW_TRANSPARENT, settings.makeDraggedWindowTransparent);
|
2020-02-10 14:59:51 +01:00
|
|
|
ptSettings.add_int_spinner(L"fancyzones_highlight_opacity", IDS_SETTINGS_HIGHLIGHT_OPACITY, settings.zoneHighlightOpacity, 0, 100, 1);
|
2020-03-25 15:38:44 +01:00
|
|
|
ptSettings.add_color_picker(L"fancyzones_zoneColor", IDS_SETTING_DESCRIPTION_ZONECOLOR, settings.zoneColor);
|
|
|
|
|
ptSettings.add_color_picker(L"fancyzones_zoneBorderColor", IDS_SETTING_DESCRIPTION_ZONE_BORDER_COLOR, settings.zoneBorderColor);
|
2020-05-27 10:55:46 -04:00
|
|
|
ptSettings.add_color_picker(L"fancyzones_zoneHighlightColor", IDS_SETTING_DESCRIPTION_ZONEHIGHLIGHTCOLOR, settings.zoneHighlightColor);
|
|
|
|
|
ptSettings.add_multiline_string(L"fancyzones_excluded_apps", IDS_SETTING_EXCLUDED_APPS_DESCRIPTION, settings.excludedApps);
|
2020-02-10 14:59:51 +01:00
|
|
|
|
|
|
|
|
return ptSettings.serialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_METHOD_INITIALIZE(Init)
|
2020-11-13 15:57:01 +03:00
|
|
|
{
|
|
|
|
|
HINSTANCE hInst = (HINSTANCE)GetModuleHandleW(nullptr);
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
m_settings = MakeFancyZonesSettings(hInst, m_moduleName, m_moduleKey);
|
|
|
|
|
Assert::IsTrue(m_settings != nullptr);
|
|
|
|
|
}
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
TEST_METHOD_CLEANUP(Cleanup)
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::remove_all(PTSettingsHelper::get_module_save_folder_location(m_moduleName));
|
|
|
|
|
}
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
TEST_METHOD (GetConfig)
|
|
|
|
|
{
|
|
|
|
|
int expectedSize = 0;
|
|
|
|
|
m_settings->GetConfig(nullptr, &expectedSize);
|
|
|
|
|
Assert::AreNotEqual(0, expectedSize);
|
2020-08-21 12:53:03 +02:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
int actualBufferSize = expectedSize;
|
|
|
|
|
PWSTR actualBuffer = new wchar_t[actualBufferSize];
|
2020-08-21 08:56:25 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
Assert::IsTrue(m_settings->GetConfig(actualBuffer, &actualBufferSize));
|
|
|
|
|
Assert::AreEqual(expectedSize, actualBufferSize);
|
|
|
|
|
}
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
TEST_METHOD (GetConfigSmallBuffer)
|
|
|
|
|
{
|
|
|
|
|
int size = 0;
|
|
|
|
|
m_settings->GetConfig(nullptr, &size);
|
|
|
|
|
Assert::AreNotEqual(0, size);
|
2020-08-21 08:56:25 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
int actualBufferSize = size - 1;
|
|
|
|
|
PWSTR actualBuffer = new wchar_t[actualBufferSize];
|
2020-08-21 12:53:03 +02:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
Assert::IsFalse(m_settings->GetConfig(actualBuffer, &actualBufferSize));
|
|
|
|
|
Assert::AreEqual(size, actualBufferSize);
|
|
|
|
|
}
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
TEST_METHOD (GetConfigNullBuffer)
|
|
|
|
|
{
|
|
|
|
|
int expectedSize = 0;
|
|
|
|
|
m_settings->GetConfig(nullptr, &expectedSize);
|
|
|
|
|
Assert::AreNotEqual(0, expectedSize);
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
int actualBufferSize = 0;
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
Assert::IsFalse(m_settings->GetConfig(nullptr, &actualBufferSize));
|
|
|
|
|
Assert::AreEqual(expectedSize, actualBufferSize);
|
|
|
|
|
}
|
2020-03-17 00:29:13 +03:00
|
|
|
|
2020-11-13 15:57:01 +03:00
|
|
|
TEST_METHOD (SetConfig)
|
|
|
|
|
{
|
|
|
|
|
//cleanup file before call set config
|
|
|
|
|
const auto settingsFile = PTSettingsHelper::get_module_save_folder_location(m_moduleName) + L"\\settings.json";
|
|
|
|
|
std::filesystem::remove(settingsFile);
|
|
|
|
|
|
|
|
|
|
const Settings expected{
|
|
|
|
|
.shiftDrag = true,
|
|
|
|
|
.mouseSwitch = true,
|
|
|
|
|
.displayChange_moveWindows = true,
|
|
|
|
|
.zoneSetChange_flashZones = false,
|
|
|
|
|
.zoneSetChange_moveWindows = true,
|
|
|
|
|
.overrideSnapHotkeys = false,
|
|
|
|
|
.moveWindowAcrossMonitors = false,
|
|
|
|
|
.appLastZone_moveWindows = true,
|
|
|
|
|
.openWindowOnActiveMonitor = false,
|
|
|
|
|
.restoreSize = false,
|
|
|
|
|
.use_cursorpos_editor_startupscreen = true,
|
|
|
|
|
.showZonesOnAllMonitors = false,
|
|
|
|
|
.spanZonesAcrossMonitors = false,
|
|
|
|
|
.makeDraggedWindowTransparent = true,
|
|
|
|
|
.zoneColor = L"#FAFAFA",
|
|
|
|
|
.zoneBorderColor = L"CCDDEE",
|
|
|
|
|
.zoneHighlightColor = L"#00AABB",
|
|
|
|
|
.zoneHighlightOpacity = 45,
|
|
|
|
|
.editorHotkey = PowerToysSettings::HotkeyObject::from_settings(false, false, false, false, VK_OEM_3),
|
2021-11-03 17:11:42 +02:00
|
|
|
.nextTabHotkey = PowerToysSettings::HotkeyObject::from_settings(false, false, false, false, VK_NEXT),
|
|
|
|
|
.prevTabHotkey = PowerToysSettings::HotkeyObject::from_settings(false, false, false, false, VK_PRIOR),
|
2020-11-13 15:57:01 +03:00
|
|
|
.excludedApps = L"app\r\napp2",
|
|
|
|
|
.excludedAppsArray = { L"APP", L"APP2" },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto config = serializedPowerToySettings(expected);
|
|
|
|
|
m_settings->SetConfig(config.c_str());
|
|
|
|
|
|
|
|
|
|
auto actual = m_settings->GetSettings();
|
|
|
|
|
compareSettings(expected, *actual);
|
|
|
|
|
|
|
|
|
|
Assert::IsTrue(std::filesystem::exists(settingsFile));
|
|
|
|
|
}
|
2020-02-10 14:59:51 +01:00
|
|
|
};
|
2020-05-26 14:12:20 -04:00
|
|
|
}
|