mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[Settings, Common.UI, runner exe] Unify exe/dll naming (#15005)
* Unify exe/dll naming - PowerToys.Runner Align naming with other exes - PowerToys Runner -> PowerToys.Runner * Unify exe/dll naming - Microsoft.PowerToys.Common.UI Project name - Microsoft.PowerToys.Common.UI -> Common.UI dll name - Microsoft.PowerToys.Common.UI.dll -> PowerToys.Common.UI.dll * Unify exe/dll naming - Settings Project names - Microsoft.PowerToys.Settings* -> Settings* Dll names - Microsoft.PowerToys.Settings*.dll -> PowerToys.Settings*.dll * Revert file autoformat * [Docs] Update paths to settings projects/files * Fix tests - Update path
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Moq;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility
|
||||
{
|
||||
public static class BackCompatTestProperties
|
||||
{
|
||||
public const string RootPathStubFiles = "..\\..\\..\\..\\src\\settings-ui\\Settings.UI.UnitTests\\BackwardsCompatibility\\TestFiles\\{0}\\Microsoft\\PowerToys\\{1}\\{2}";
|
||||
|
||||
// Using Ordinal since this is used internally for a path
|
||||
private static readonly Expression<Func<string, bool>> SettingsFilterExpression = s => s == null || s.Contains("Microsoft\\PowerToys\\settings.json", StringComparison.Ordinal);
|
||||
|
||||
internal class MockSettingsRepository<T> : ISettingsRepository<T>
|
||||
where T : ISettingsConfig, new()
|
||||
{
|
||||
private readonly ISettingsUtils _settingsUtils;
|
||||
private T _settingsConfig;
|
||||
|
||||
public MockSettingsRepository(ISettingsUtils settingsUtils)
|
||||
{
|
||||
_settingsUtils = settingsUtils;
|
||||
}
|
||||
|
||||
public T SettingsConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
T settingsItem = new T();
|
||||
_settingsConfig = _settingsUtils.GetSettingsOrDefault<T>(settingsItem.GetModuleName());
|
||||
return _settingsConfig;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
_settingsConfig = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Mock<IFile> GetModuleIOProvider(string version, string module, string fileName)
|
||||
{
|
||||
var stubSettingsPath = StubSettingsPath(version, module, fileName);
|
||||
Expression<Func<string, bool>> filterExpression = ModuleFilterExpression(module);
|
||||
return IIOProviderMocks.GetMockIOReadWithStubFile(stubSettingsPath, filterExpression);
|
||||
}
|
||||
|
||||
public static string StubGeneralSettingsPath(string version)
|
||||
{
|
||||
return StubSettingsPath(version, string.Empty, "settings.json");
|
||||
}
|
||||
|
||||
public static string StubSettingsPath(string version, string module, string fileName)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, BackCompatTestProperties.RootPathStubFiles, version, module, fileName);
|
||||
}
|
||||
|
||||
public static void VerifyModuleIOProviderWasRead(Mock<IFile> provider, string module, int expectedCallCount)
|
||||
{
|
||||
if (provider == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
}
|
||||
|
||||
Expression<Func<string, bool>> filterExpression = ModuleFilterExpression(module);
|
||||
|
||||
IIOProviderMocks.VerifyIOReadWithStubFile(provider, filterExpression, expectedCallCount);
|
||||
}
|
||||
|
||||
private static Expression<Func<string, bool>> ModuleFilterExpression(string module)
|
||||
{
|
||||
// Using Ordinal since this is used internally for a path
|
||||
return s => s == null || s.Contains(module, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static Mock<IFile> GetGeneralSettingsIOProvider(string version)
|
||||
{
|
||||
var stubGeneralSettingsPath = StubGeneralSettingsPath(version);
|
||||
return IIOProviderMocks.GetMockIOReadWithStubFile(stubGeneralSettingsPath, SettingsFilterExpression);
|
||||
}
|
||||
|
||||
public static void VerifyGeneralSettingsIOProviderWasRead(Mock<IFile> provider, int expectedCallCount)
|
||||
{
|
||||
if (provider == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
}
|
||||
|
||||
IIOProviderMocks.VerifyIOReadWithStubFile(provider, SettingsFilterExpression, expectedCallCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"properties":{"ActivationShortcut":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":222,"key":""},"changecursor":{"value":false},"copiedcolorrepresentation":1},"name":"ColorPicker","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"app-zone-history":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":"1.0","name":"FancyZones","properties":{"fancyzones_shiftDrag":{"value":false},"fancyzones_mouseSwitch":{"value":true},"fancyzones_overrideSnapHotkeys":{"value":true},"fancyzones_moveWindowAcrossMonitors":{"value":true},"fancyzones_moveWindowsBasedOnPosition":{"value":true},"fancyzones_displayChange_moveWindows":{"value":true},"fancyzones_zoneSetChange_moveWindows":{"value":true},"fancyzones_appLastZone_moveWindows":{"value":true},"fancyzones_openWindowOnActiveMonitor":{"value":true},"fancyzones_restoreSize":{"value":true},"use_cursorpos_editor_startupscreen":{"value":false},"fancyzones_show_on_all_monitors":{"value":true},"fancyzones_span_zones_across_monitors":{"value":true},"fancyzones_makeDraggedWindowTransparent":{"value":true},"fancyzones_zoneColor":{"value":"#B53AFF"},"fancyzones_zoneBorderColor":{"value":"#FF6508"},"fancyzones_zoneHighlightColor":{"value":"#9BD7D6"},"fancyzones_highlight_opacity":{"value":26},"fancyzones_editor_hotkey":{"value":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":80,"key":""}},"fancyzones_excluded_apps":{"value":""}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"devices":[],"custom-zone-sets":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"Properties":{"svg-previewer-toggle-setting":{"value":false},"svg-thumbnail-toggle-setting":{"value":false},"md-previewer-toggle-setting":{"value":false}},"name":"File Explorer","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false}
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"properties": {
|
||||
"imageresizer_selectedSizeIndex": {
|
||||
"value": 0
|
||||
},
|
||||
"imageresizer_shrinkOnly": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_replace": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_ignoreOrientation": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_jpegQualityLevel": {
|
||||
"value": 92
|
||||
},
|
||||
"imageresizer_pngInterlaceOption": {
|
||||
"value": 1
|
||||
},
|
||||
"imageresizer_tiffCompressOption": {
|
||||
"value": 4
|
||||
},
|
||||
"imageresizer_fileName": {
|
||||
"value": "%1 (%2)"
|
||||
},
|
||||
"imageresizer_sizes": {
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 853,
|
||||
"height": 479,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1365,
|
||||
"height": 767,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1919,
|
||||
"height": 1079,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 319,
|
||||
"height": 567,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"imageresizer_keepDateModified": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_fallbackEncoder": {
|
||||
"value": "163bcc30-e2e9-4f0b-961d-a3e9fdb788a3"
|
||||
},
|
||||
"imageresizer_customSize": {
|
||||
"value": {
|
||||
"Id": 4,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "custom",
|
||||
"fit": 1,
|
||||
"width": 1024,
|
||||
"height": 640,
|
||||
"unit": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "Image Resizer",
|
||||
"version": "1"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 853,
|
||||
"height": 479,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1365,
|
||||
"height": 767,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1919,
|
||||
"height": 1079,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 319,
|
||||
"height": 567,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"remapKeys":{"inProcess":[{"originalKeys":"83","newRemapKeys":"65"}]},"remapShortcuts":{"global":[{"originalKeys":"160;70","newRemapKeys":"160;20"}],"appSpecific":[]}}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"activeConfiguration":{"value":"default"},"keyboardConfigurations":{"value":["default"]}},"name":"Keyboard Manager","version":"1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false,"ShowIcon":false,"ExtendedContextMenuOnly":true,"PersistState":false,"MRUEnabled":true,"MaxMRUSize":13,"SearchText":"","ReplaceText":""}
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"search_result_preference":"most_recently_used","search_type_preference":"application_name","maximum_number_of_results":8,"open_powerlauncher":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":186,"key":""},"open_file_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"copy_path_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"open_console":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"override_win_r_key":false,"override_win_s_key":false,"ignore_hotkeys_in_fullscreen":false,"disable_drive_detection_warning":true,"clear_input_on_launch":true},"name":"PowerToys Run","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"overlay_opacity":{"value":36},"press_time":{"value":1050},"theme":{"value":"dark"}},"name":"Shortcut Guide","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"packaged":false,"startup":false,"enabled":{"ColorPicker":false,"FancyZones":false,"File Explorer":true,"Image Resizer":false,"Keyboard Manager":false,"PowerRename":false,"PowerToys Run":false,"Shortcut Guide":false},"is_elevated":false,"run_elevated":false,"download_updates_automatically":false,"is_admin":true,"theme":"light","system_theme":"dark","powertoys_version":"v0.21.1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"github_update_last_checked_date":"1601059000","pending_update":false,"pending_installer_filename":""}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"ActivationShortcut":{"win":true,"ctrl":false,"alt":false,"shift":true,"code":67,"key":""},"changecursor":{"value":false},"copiedcolorrepresentation":0},"name":"ColorPicker","version":"1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"app-zone-history":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":"1.0","name":"FancyZones","properties":{"fancyzones_shiftDrag":{"value":false},"fancyzones_mouseSwitch":{"value":true},"fancyzones_overrideSnapHotkeys":{"value":true},"fancyzones_moveWindowAcrossMonitors":{"value":true},"fancyzones_displayChange_moveWindows":{"value":true},"fancyzones_zoneSetChange_moveWindows":{"value":true},"fancyzones_virtualDesktopChange_moveWindows":{"value":true},"fancyzones_appLastZone_moveWindows":{"value":true},"use_cursorpos_editor_startupscreen":{"value":false},"fancyzones_show_on_all_monitors":{"value":true},"fancyzones_makeDraggedWindowTransparent":{"value":true},"fancyzones_zoneColor":{"value":"#F5FCFF"},"fancyzones_zoneBorderColor":{"value":"#365E5C"},"fancyzones_zoneHighlightColor":{"value":"#D77F70"},"fancyzones_highlight_opacity":{"value":93},"fancyzones_editor_hotkey":{"value":{"win":false,"ctrl":false,"alt":false,"shift":true,"key":"D","code":68}},"fancyzones_excluded_apps":{"value":""}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"app-zone-history":[],"devices":[{"device-id":"LEN4140#4&2cf01444&0&UID265988_1920_1200_{FAD9BC94-3335-41ED-A550-A14A1B4E2FB7}","active-zoneset":{"uuid":"{0C77400D-EBC4-40EB-A820-262706297DD0}","type":"priority-grid"},"editor-show-spacing":true,"editor-spacing":16,"editor-zone-count":3}],"custom-zone-sets":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"svg-previewer-toggle-setting":{"value":false},"md-previewer-toggle-setting":{"value":false}},"name":"File Explorer","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false}
|
||||
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "Image Resizer",
|
||||
"properties": {
|
||||
"imageresizer_selectedSizeIndex": {
|
||||
"value": 0
|
||||
},
|
||||
"imageresizer_shrinkOnly": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_replace": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_ignoreOrientation": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_jpegQualityLevel": {
|
||||
"value": 89
|
||||
},
|
||||
"imageresizer_pngInterlaceOption": {
|
||||
"value": 2
|
||||
},
|
||||
"imageresizer_tiffCompressOption": {
|
||||
"value": 2
|
||||
},
|
||||
"imageresizer_fileName": {
|
||||
"value": "%1 (%2)"
|
||||
},
|
||||
"imageresizer_sizes": {
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"imageresizer_keepDateModified": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_fallbackEncoder": {
|
||||
"value": "163bcc30-e2e9-4f0b-961d-a3e9fdb788a3"
|
||||
},
|
||||
"imageresizer_customSize": {
|
||||
"value": {
|
||||
"Id": 4,
|
||||
"name": "custom",
|
||||
"fit": 1,
|
||||
"width": 1024,
|
||||
"height": 640,
|
||||
"unit": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 1,
|
||||
"height": 1,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"remapKeys":{"inProcess":[{"originalKeys":"65","newRemapKeys":"105"}]},"remapShortcuts":{"global":[{"originalKeys":"160;70","newRemapKeys":"160;82"}]}}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"activeConfiguration":{"value":"default"},"keyboardConfigurations":{"value":["default"]}},"name":"Keyboard Manager","version":"1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false,"ShowIcon":false,"ExtendedContextMenuOnly":true,"PersistState":false,"MRUEnabled":true,"MaxMRUSize":8,"SearchText":"","ReplaceText":""}
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"search_result_preference":"most_recently_used","search_type_preference":"application_name","maximum_number_of_results":10,"open_powerlauncher":{"win":false,"ctrl":false,"alt":false,"shift":true,"key":"P","code":80},"open_file_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"key":"","code":0},"copy_path_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"key":"","code":0},"open_console":{"win":false,"ctrl":false,"alt":false,"shift":false,"key":"","code":0},"override_win_r_key":false,"override_win_s_key":false},"name":"PowerToys Run","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"Shortcut Guide","properties":{"overlay_opacity":{"value":51},"press_time":{"value":100},"theme":{"value":"dark"}},"version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"packaged":false,"startup":false,"enabled":{"FancyZones":false,"File Explorer":true,"Image Resizer":false,"Keyboard Manager":false,"PowerRename":false,"PowerToys Run":false,"Shortcut Guide":false},"is_elevated":false,"run_elevated":false,"download_updates_automatically":false,"is_admin":true,"theme":"dark","system_theme":"dark","powertoys_version":"v0.18.2"}
|
||||
@@ -0,0 +1 @@
|
||||
{"github_update_last_checked_date":"1601047811","pending_update":false}
|
||||
@@ -0,0 +1 @@
|
||||
{"app-zone-history":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":"1.0","name":"FancyZones","properties":{"fancyzones_shiftDrag":{"value":true},"fancyzones_mouseSwitch":{"value":false},"fancyzones_overrideSnapHotkeys":{"value":false},"fancyzones_moveWindowAcrossMonitors":{"value":false},"fancyzones_displayChange_moveWindows":{"value":false},"fancyzones_zoneSetChange_moveWindows":{"value":false},"fancyzones_appLastZone_moveWindows":{"value":false},"use_cursorpos_editor_startupscreen":{"value":true},"fancyzones_show_on_all_monitors":{"value":false},"fancyzones_makeDraggedWindowTransparent":{"value":false},"fancyzones_zoneColor":{"value":"#F5FCFF"},"fancyzones_zoneBorderColor":{"value":"#FFFFFF"},"fancyzones_zoneHighlightColor":{"value":"#0078D7"},"fancyzones_highlight_opacity":{"value":50},"fancyzones_editor_hotkey":{"value":{"win":true,"ctrl":false,"alt":false,"shift":false,"key":"`","code":192}},"fancyzones_excluded_apps":{"value":""}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"devices":[],"custom-zone-sets":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"svg-previewer-toggle-setting":{"value":false},"md-previewer-toggle-setting":{"value":false}},"name":"File Explorer","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":true}
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"version": "1",
|
||||
"name": "Image Resizer",
|
||||
"properties": {
|
||||
"imageresizer_selectedSizeIndex": {
|
||||
"value": 0
|
||||
},
|
||||
"imageresizer_shrinkOnly": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_replace": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_ignoreOrientation": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_jpegQualityLevel": {
|
||||
"value": 89
|
||||
},
|
||||
"imageresizer_pngInterlaceOption": {
|
||||
"value": 1
|
||||
},
|
||||
"imageresizer_tiffCompressOption": {
|
||||
"value": 2
|
||||
},
|
||||
"imageresizer_fileName": {
|
||||
"value": "%1 (%2)"
|
||||
},
|
||||
"imageresizer_sizes": {
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 850,
|
||||
"height": 480,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1363,
|
||||
"height": 768,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1917,
|
||||
"height": 1080,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 316,
|
||||
"height": 568,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"imageresizer_keepDateModified": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_fallbackEncoder": {
|
||||
"value": "57a37caa-367a-4540-916b-f183c5093a4b"
|
||||
},
|
||||
"imageresizer_customSize": {
|
||||
"value": {
|
||||
"Id": 4,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "custom",
|
||||
"fit": 1,
|
||||
"width": 1024,
|
||||
"height": 640,
|
||||
"unit": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 850,
|
||||
"height": 480,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1363,
|
||||
"height": 768,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1917,
|
||||
"height": 1080,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 316,
|
||||
"height": 568,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"remapKeys":{"inProcess":[{"originalKeys":"68","newRemapKeys":"65"}]},"remapShortcuts":{"global":[{"originalKeys":"160;20","newRemapKeys":"160;9"}]}}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"activeConfiguration":{"value":"default"},"keyboardConfigurations":{"value":["default"]}},"name":"Keyboard Manager","version":"1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false,"ShowIcon":false,"ExtendedContextMenuOnly":true,"PersistState":false,"MRUEnabled":false,"MaxMRUSize":10,"SearchText":"","ReplaceText":""}
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"search_result_preference":"most_recently_used","search_type_preference":"application_name","maximum_number_of_results":8,"open_powerlauncher":{"win":false,"ctrl":false,"alt":false,"shift":true,"key":"P","code":80},"open_file_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"key":"","code":0},"copy_path_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"key":"","code":0},"open_console":{"win":false,"ctrl":false,"alt":false,"shift":false,"key":"","code":0},"override_win_r_key":false,"override_win_s_key":false,"ignore_hotkeys_in_fullscreen":true},"name":"PowerToys Run","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"Shortcut Guide","properties":{"overlay_opacity":{"value":32},"press_time":{"value":1150},"theme":{"value":"system"}},"version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"packaged":false,"startup":true,"enabled":{"FancyZones":true,"File Explorer":true,"Image Resizer":true,"Keyboard Manager":false,"PowerRename":false,"PowerToys Run":true,"Shortcut Guide":false},"is_elevated":false,"run_elevated":false,"download_updates_automatically":false,"is_admin":true,"theme":"light","system_theme":"dark","powertoys_version":"v0.19.2"}
|
||||
@@ -0,0 +1 @@
|
||||
{"github_update_last_checked_date":"1601050757","pending_update":false,"pending_installer_filename":""}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"ActivationShortcut":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":80,"key":""},"changecursor":{"value":false},"copiedcolorrepresentation":1},"name":"ColorPicker","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"app-zone-history":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":"1.0","name":"FancyZones","properties":{"fancyzones_shiftDrag":{"value":false},"fancyzones_mouseSwitch":{"value":true},"fancyzones_overrideSnapHotkeys":{"value":true},"fancyzones_moveWindowAcrossMonitors":{"value":true},"fancyzones_displayChange_moveWindows":{"value":true},"fancyzones_zoneSetChange_moveWindows":{"value":true},"fancyzones_appLastZone_moveWindows":{"value":true},"fancyzones_openWindowOnActiveMonitor":{"value":true},"fancyzones_restoreSize":{"value":true},"use_cursorpos_editor_startupscreen":{"value":false},"fancyzones_show_on_all_monitors":{"value":true},"fancyzones_makeDraggedWindowTransparent":{"value":true},"fancyzones_zoneColor":{"value":"#18FCFF"},"fancyzones_zoneBorderColor":{"value":"#C0FF43"},"fancyzones_zoneHighlightColor":{"value":"#0016D7"},"fancyzones_highlight_opacity":{"value":25},"fancyzones_editor_hotkey":{"value":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":87,"key":""}},"fancyzones_excluded_apps":{"value":""}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"devices":[],"custom-zone-sets":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"Properties":{"svg-previewer-toggle-setting":{"value":false},"svg-thumbnail-toggle-setting":{"value":false},"md-previewer-toggle-setting":{"value":false}},"name":"File Explorer","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":true}
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"properties": {
|
||||
"imageresizer_selectedSizeIndex": {
|
||||
"value": 0
|
||||
},
|
||||
"imageresizer_shrinkOnly": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_replace": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_ignoreOrientation": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_jpegQualityLevel": {
|
||||
"value": 90
|
||||
},
|
||||
"imageresizer_pngInterlaceOption": {
|
||||
"value": 0
|
||||
},
|
||||
"imageresizer_tiffCompressOption": {
|
||||
"value": 0
|
||||
},
|
||||
"imageresizer_fileName": {
|
||||
"value": "%1 (%2)"
|
||||
},
|
||||
"imageresizer_sizes": {
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 854,
|
||||
"height": 480,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1366,
|
||||
"height": 768,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 320,
|
||||
"height": 568,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"imageresizer_keepDateModified": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_fallbackEncoder": {
|
||||
"value": "19e4a5aa-5662-4fc5-a0c0-1758028e1057"
|
||||
},
|
||||
"imageresizer_customSize": {
|
||||
"value": {
|
||||
"Id": 4,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "custom",
|
||||
"fit": 1,
|
||||
"width": 1024,
|
||||
"height": 640,
|
||||
"unit": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "Image Resizer",
|
||||
"version": "1"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 854,
|
||||
"height": 480,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1366,
|
||||
"height": 768,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 320,
|
||||
"height": 568,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"remapKeys":{"inProcess":[{"originalKeys":"97","newRemapKeys":"65"},{"originalKeys":"83","newRemapKeys":"96"}]},"remapShortcuts":{"global":[{"originalKeys":"162;164;79","newRemapKeys":"164;160;72"}],"appSpecific":[]}}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"activeConfiguration":{"value":"default"},"keyboardConfigurations":{"value":["default"]}},"name":"Keyboard Manager","version":"1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false,"ShowIcon":false,"ExtendedContextMenuOnly":true,"PersistState":false,"MRUEnabled":false,"MaxMRUSize":6,"SearchText":"","ReplaceText":""}
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"search_result_preference":"most_recently_used","search_type_preference":"application_name","maximum_number_of_results":8,"open_powerlauncher":{"win":true,"ctrl":false,"alt":false,"shift":false,"code":80,"key":""},"open_file_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"copy_path_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"open_console":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"override_win_r_key":false,"override_win_s_key":false,"ignore_hotkeys_in_fullscreen":true,"disable_drive_detection_warning":true,"clear_input_on_launch":true},"name":"PowerToys Run","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"overlay_opacity":{"value":21},"press_time":{"value":650},"theme":{"value":"dark"}},"name":"Shortcut Guide","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"packaged":false,"startup":false,"enabled":{"ColorPicker":true,"FancyZones":false,"File Explorer":true,"Image Resizer":true,"Keyboard Manager":false,"PowerRename":false,"PowerToys Run":false,"Shortcut Guide":false},"is_elevated":false,"run_elevated":false,"download_updates_automatically":false,"is_admin":true,"theme":"light","system_theme":"dark","powertoys_version":"v0.20.1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"github_update_last_checked_date":"1601057084","pending_update":false,"pending_installer_filename":""}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"ActivationShortcut":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":83,"key":""},"changecursor":{"value":false},"copiedcolorrepresentation":1},"name":"ColorPicker","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"app-zone-history":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":"1.0","name":"FancyZones","properties":{"fancyzones_shiftDrag":{"value":false},"fancyzones_mouseSwitch":{"value":true},"fancyzones_overrideSnapHotkeys":{"value":true},"fancyzones_moveWindowAcrossMonitors":{"value":true},"fancyzones_moveWindowsBasedOnPosition":{"value":true},"fancyzones_displayChange_moveWindows":{"value":true},"fancyzones_zoneSetChange_moveWindows":{"value":true},"fancyzones_appLastZone_moveWindows":{"value":true},"fancyzones_openWindowOnActiveMonitor":{"value":true},"fancyzones_restoreSize":{"value":true},"use_cursorpos_editor_startupscreen":{"value":true},"fancyzones_show_on_all_monitors":{"value":true},"fancyzones_span_zones_across_monitors":{"value":true},"fancyzones_makeDraggedWindowTransparent":{"value":true},"fancyzones_zoneColor":{"value":"#FF6B1A"},"fancyzones_zoneBorderColor":{"value":"#C4B9FF"},"fancyzones_zoneHighlightColor":{"value":"#D7115F"},"fancyzones_highlight_opacity":{"value":15},"fancyzones_editor_hotkey":{"value":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":83,"key":""}},"fancyzones_excluded_apps":{"value":""}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"devices":[],"custom-zone-sets":[]}
|
||||
@@ -0,0 +1 @@
|
||||
{"Properties":{"svg-previewer-toggle-setting":{"value":false},"svg-thumbnail-toggle-setting":{"value":false},"md-previewer-toggle-setting":{"value":false}},"name":"File Explorer","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false}
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"properties": {
|
||||
"imageresizer_selectedSizeIndex": {
|
||||
"value": 0
|
||||
},
|
||||
"imageresizer_shrinkOnly": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_replace": {
|
||||
"value": false
|
||||
},
|
||||
"imageresizer_ignoreOrientation": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_jpegQualityLevel": {
|
||||
"value": 89
|
||||
},
|
||||
"imageresizer_pngInterlaceOption": {
|
||||
"value": 1
|
||||
},
|
||||
"imageresizer_tiffCompressOption": {
|
||||
"value": 1
|
||||
},
|
||||
"imageresizer_fileName": {
|
||||
"value": "%1 (%2)"
|
||||
},
|
||||
"imageresizer_sizes": {
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 853,
|
||||
"height": 479,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1365,
|
||||
"height": 767,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1919,
|
||||
"height": 1079,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 319,
|
||||
"height": 567,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"imageresizer_keepDateModified": {
|
||||
"value": true
|
||||
},
|
||||
"imageresizer_fallbackEncoder": {
|
||||
"value": "163bcc30-e2e9-4f0b-961d-a3e9fdb788a3"
|
||||
},
|
||||
"imageresizer_customSize": {
|
||||
"value": {
|
||||
"Id": 4,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "custom",
|
||||
"fit": 1,
|
||||
"width": 1024,
|
||||
"height": 640,
|
||||
"unit": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "Image Resizer",
|
||||
"version": "1"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"value": [
|
||||
{
|
||||
"Id": 0,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Small",
|
||||
"fit": 1,
|
||||
"width": 853,
|
||||
"height": 479,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Medium",
|
||||
"fit": 1,
|
||||
"width": 1365,
|
||||
"height": 767,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Large",
|
||||
"fit": 1,
|
||||
"width": 1919,
|
||||
"height": 1079,
|
||||
"unit": 3
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"ExtraBoxOpacity": 100,
|
||||
"EnableEtraBoxes": true,
|
||||
"name": "Phone",
|
||||
"fit": 1,
|
||||
"width": 319,
|
||||
"height": 567,
|
||||
"unit": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"remapKeys":{"inProcess":[{"originalKeys":"65","newRemapKeys":"69"}]},"remapShortcuts":{"global":[{"originalKeys":"160;68","newRemapKeys":"9"}],"appSpecific":[]}}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"activeConfiguration":{"value":"default"},"keyboardConfigurations":{"value":["default"]}},"name":"Keyboard Manager","version":"1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"Enabled":false,"ShowIcon":false,"ExtendedContextMenuOnly":true,"PersistState":false,"MRUEnabled":true,"MaxMRUSize":6,"SearchText":"","ReplaceText":""}
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"search_result_preference":"most_recently_used","search_type_preference":"application_name","maximum_number_of_results":1,"open_powerlauncher":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":68,"key":""},"open_file_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"copy_path_location":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"open_console":{"win":false,"ctrl":false,"alt":false,"shift":false,"code":0,"key":""},"override_win_r_key":false,"override_win_s_key":false,"ignore_hotkeys_in_fullscreen":true,"disable_drive_detection_warning":true,"clear_input_on_launch":true},"name":"PowerToys Run","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"properties":{"overlay_opacity":{"value":92},"press_time":{"value":850},"theme":{"value":"dark"}},"name":"Shortcut Guide","version":"1.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":"1.0","name":"Video Conference","properties":{"mute_camera_and_microphone_hotkey":{"value":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":73,"key":""}},"mute_microphone_hotkey":{"value":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":68,"key":""}},"mute_camera_hotkey":{"value":{"win":false,"ctrl":false,"alt":false,"shift":true,"code":86,"key":""}},"selected_camera":{"value":"USB Video Device"},"toolbar_position":{"value":"Bottom center"},"toolbar_monitor":{"value":"All monitors"},"camera_overlay_image_path":{"value":""},"theme":{"value":"light"},"hide_toolbar_when_unmuted":{"value":false}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"packaged":false,"startup":false,"enabled":{"ColorPicker":false,"FancyZones":false,"File Explorer":true,"Image Resizer":false,"Keyboard Manager":false,"PowerRename":false,"PowerToys Run":false,"Shortcut Guide":true,"Video Conference":false},"is_elevated":false,"run_elevated":false,"download_updates_automatically":false,"is_admin":true,"theme":"light","system_theme":"dark","powertoys_version":"v0.22.0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"github_update_last_checked_date":"1601060698","pending_update":false,"pending_installer_filename":""}
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
using Moq;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.UnitTests.Mocks
|
||||
{
|
||||
internal static class IIOProviderMocks
|
||||
{
|
||||
/// <summary>
|
||||
/// This method mocks an IO provider to validate tests which required saving to a file, and then reading the contents of that file, or verifying it exists
|
||||
/// </summary>
|
||||
/// <returns>Mocked IO Provider</returns>
|
||||
internal static Mock<IIOProvider> GetMockIOProviderForSaveLoadExists()
|
||||
{
|
||||
string savePath = string.Empty;
|
||||
string saveContent = string.Empty;
|
||||
var mockIOProvider = new Mock<IIOProvider>();
|
||||
mockIOProvider.Setup(x => x.WriteAllText(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Callback<string, string>((path, content) =>
|
||||
{
|
||||
savePath = path;
|
||||
saveContent = content;
|
||||
});
|
||||
|
||||
// Using Ordinal since this is used internally for a path
|
||||
mockIOProvider.Setup(x => x.ReadAllText(It.Is<string>(x => x.Equals(savePath, StringComparison.Ordinal))))
|
||||
.Returns(() => saveContent);
|
||||
|
||||
// Using Ordinal since this is used internally for a path
|
||||
mockIOProvider.Setup(x => x.FileExists(It.Is<string>(x => x.Equals(savePath, StringComparison.Ordinal))))
|
||||
.Returns(true);
|
||||
|
||||
// Using Ordinal since this is used internally for a path
|
||||
mockIOProvider.Setup(x => x.FileExists(It.Is<string>(x => !x.Equals(savePath, StringComparison.Ordinal))))
|
||||
.Returns(false);
|
||||
|
||||
return mockIOProvider;
|
||||
}
|
||||
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IFile File = FileSystem.File;
|
||||
|
||||
/// <summary>
|
||||
/// This method mocks an IO provider so that it will always return data at the savePath location.
|
||||
/// This mock is specific to a given module, and is verifiable that the stub file was read.
|
||||
/// </summary>
|
||||
/// <param name="savePath">The path to the stub settings file</param>
|
||||
/// <param name="filterExpression">The substring in the path that identifies the module eg. Microsoft\\PowerToys\\ColorPicker</param>
|
||||
/// <returns>Mocked IFile</returns>
|
||||
internal static Mock<IFile> GetMockIOReadWithStubFile(string savePath, Expression<Func<string, bool>> filterExpression)
|
||||
{
|
||||
string saveContent = File.ReadAllText(savePath);
|
||||
var fileMock = new Mock<IFile>();
|
||||
|
||||
fileMock.Setup(x => x.ReadAllText(It.Is<string>(filterExpression)))
|
||||
.Returns(() => saveContent).Verifiable();
|
||||
|
||||
fileMock.Setup(x => x.Exists(It.Is<string>(filterExpression)))
|
||||
.Returns(true);
|
||||
|
||||
return fileMock;
|
||||
}
|
||||
|
||||
internal static void VerifyIOReadWithStubFile(Mock<IFile> fileMock, Expression<Func<string, bool>> filterExpression, int expectedCallCount)
|
||||
{
|
||||
fileMock.Verify(x => x.ReadAllText(It.Is<string>(filterExpression)), Times.Exactly(expectedCallCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
using Moq;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.UnitTests.Mocks
|
||||
{
|
||||
internal static class ISettingsUtilsMocks
|
||||
{
|
||||
// Stubs out empty values for imageresizersettings and general settings as needed by the imageresizer viewmodel
|
||||
internal static Mock<ISettingsUtils> GetStubSettingsUtils<T>()
|
||||
where T : ISettingsConfig, new()
|
||||
{
|
||||
var settingsUtils = new Mock<ISettingsUtils>();
|
||||
settingsUtils
|
||||
.Setup(x => x.GetSettingsOrDefault<T>(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns(new T());
|
||||
|
||||
settingsUtils
|
||||
.Setup(x => x.GetSettings<T>(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns(new T());
|
||||
|
||||
return settingsUtils;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UnitTest;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Schema;
|
||||
|
||||
namespace CommonLibTest
|
||||
{
|
||||
[TestClass]
|
||||
public class BasePTModuleSettingsTest
|
||||
{
|
||||
// Work around for System.JSON required properties:
|
||||
// https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to.
|
||||
// Test also fails when the attributes are not initialized i.e they have null values.
|
||||
[TestMethod]
|
||||
[ObsoleteAttribute("This test method is obsolete.", true)]
|
||||
public void ToJsonStringShouldReturnValidJSONOfModelWhenSuccessful()
|
||||
{
|
||||
// Mock Disk access
|
||||
var mockFileSystem = new MockFileSystem();
|
||||
var settingsUtils = new SettingsUtils(mockFileSystem);
|
||||
|
||||
// Arrange
|
||||
string file_name = "test\\BasePTModuleSettingsTest";
|
||||
string expectedSchemaText = @"
|
||||
{
|
||||
'$schema': 'http://json-schema.org/draft-04/schema#',
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string'
|
||||
},
|
||||
'version': {
|
||||
'type': 'string'
|
||||
}
|
||||
},
|
||||
'additionalProperties': false
|
||||
}";
|
||||
|
||||
string testSettingsConfigs = new BasePTSettingsTest().ToJsonString();
|
||||
settingsUtils.SaveSettings(testSettingsConfigs, file_name);
|
||||
JsonSchema expectedSchema = JsonSchema.Parse(expectedSchemaText);
|
||||
|
||||
// Act
|
||||
JObject actualSchema = JObject.Parse(settingsUtils.GetSettingsOrDefault<BasePTSettingsTest>(file_name).ToJsonString());
|
||||
bool valid = actualSchema.IsValid(expectedSchema);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(valid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UnitTest
|
||||
{
|
||||
public class BasePTSettingsTest : BasePTModuleSettings, ISettingsConfig
|
||||
{
|
||||
public BasePTSettingsTest()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Version = string.Empty;
|
||||
}
|
||||
|
||||
public string GetModuleName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public bool UpgradeSettingsConfiguration()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace CommonLibTest
|
||||
{
|
||||
[TestClass]
|
||||
public class HelperTest
|
||||
{
|
||||
public static void TestStringIsSmaller(string v1, string v2)
|
||||
{
|
||||
var res = Helper.CompareVersions(v1, v2);
|
||||
Assert.IsTrue(res < 0);
|
||||
}
|
||||
|
||||
public static void TestStringsAreEqual(string v1, string v2)
|
||||
{
|
||||
var res = Helper.CompareVersions(v1, v2);
|
||||
Assert.IsTrue(res == 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HelperCompareVersionsShouldBeEqualWhenSuccessful()
|
||||
{
|
||||
TestStringsAreEqual("v0.0.0", "v0.0.0");
|
||||
TestStringsAreEqual("v0.1.1", "v0.1.1");
|
||||
TestStringsAreEqual("v1.1.1", "v1.1.1");
|
||||
TestStringsAreEqual("v1.999.99", "v1.999.99");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HelperCompareVersionsShouldBeSmallerWhenSuccessful()
|
||||
{
|
||||
TestStringIsSmaller("v0.0.0", "v0.0.1");
|
||||
TestStringIsSmaller("v0.0.0", "v0.1.0");
|
||||
TestStringIsSmaller("v0.0.0", "v1.0.0");
|
||||
TestStringIsSmaller("v1.0.1", "v1.0.2");
|
||||
TestStringIsSmaller("v1.1.1", "v1.1.2");
|
||||
TestStringIsSmaller("v1.1.1", "v1.2.0");
|
||||
TestStringIsSmaller("v1.999.99", "v2.0.0");
|
||||
TestStringIsSmaller("v1.0.99", "v1.2.0");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void HelperCompareVersionsShouldThrowBadFormatWhenNoVersionString()
|
||||
{
|
||||
Helper.CompareVersions("v0.0.1", string.Empty);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void HelperCompareVersionsShouldThrowBadFormatWhenShortVersionString()
|
||||
{
|
||||
Helper.CompareVersions("v0.0.1", "v0.1");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void HelperCompareVersionsShouldThrowBadFormatWhenLongVersionString()
|
||||
{
|
||||
Helper.CompareVersions("v0.0.1", "v0.0.0.1");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void HelperCompareVersionsShouldThrowBadFormatWhenItIsNotAVersionString()
|
||||
{
|
||||
Helper.CompareVersions("v0.0.1", "HelloWorld");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace CommonLibTest
|
||||
{
|
||||
[TestClass]
|
||||
public class SettingsRepositoryTest
|
||||
{
|
||||
private static Task<SettingsRepository<GeneralSettings>> GetSettingsRepository(ISettingsUtils settingsUtils)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
return SettingsRepository<GeneralSettings>.GetInstance(settingsUtils);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SettingsRepositoryInstanceWhenCalledMustReturnSameObject()
|
||||
{
|
||||
// The singleton class Settings Repository must always have a single instance
|
||||
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
|
||||
// Arrange and Act
|
||||
SettingsRepository<GeneralSettings> firstInstance = SettingsRepository<GeneralSettings>.GetInstance(mockSettingsUtils.Object);
|
||||
SettingsRepository<GeneralSettings> secondInstance = SettingsRepository<GeneralSettings>.GetInstance(mockSettingsUtils.Object);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(object.ReferenceEquals(firstInstance, secondInstance));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SettingsRepositoryInstanceMustBeTheSameAcrossThreads()
|
||||
{
|
||||
// Multiple tasks try to access and initialize the settings repository class, however they must all access the same settings Repository object.
|
||||
|
||||
// Arrange
|
||||
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
List<Task<SettingsRepository<GeneralSettings>>> settingsRepoTasks = new List<Task<SettingsRepository<GeneralSettings>>>();
|
||||
int numberOfTasks = 100;
|
||||
|
||||
for (int i = 0; i < numberOfTasks; i++)
|
||||
{
|
||||
settingsRepoTasks.Add(GetSettingsRepository(mockSettingsUtils.Object));
|
||||
}
|
||||
|
||||
// Act
|
||||
Task.WaitAll(settingsRepoTasks.ToArray());
|
||||
|
||||
// Assert
|
||||
for (int i = 0; i < numberOfTasks - 1; i++)
|
||||
{
|
||||
Assert.IsTrue(object.ReferenceEquals(settingsRepoTasks[i].Result, settingsRepoTasks[i + 1].Result));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
using Microsoft.PowerToys.Settings.UnitTest;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace CommonLibTest
|
||||
{
|
||||
[TestClass]
|
||||
public class SettingsUtilsTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void SaveSettingsSaveSettingsToFileWhenFilePathExists()
|
||||
{
|
||||
// Arrange
|
||||
var mockFileSystem = new MockFileSystem();
|
||||
var settingsUtils = new SettingsUtils(mockFileSystem);
|
||||
|
||||
string file_name = "\\test";
|
||||
string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
|
||||
|
||||
BasePTSettingsTest expected_json = JsonSerializer.Deserialize<BasePTSettingsTest>(file_contents_correct_json_content);
|
||||
|
||||
// Act
|
||||
settingsUtils.SaveSettings(file_contents_correct_json_content, file_name);
|
||||
BasePTSettingsTest actual_json = settingsUtils.GetSettingsOrDefault<BasePTSettingsTest>(file_name);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expected_json.ToJsonString(), actual_json.ToJsonString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SaveSettingsShouldCreateFileWhenFilePathIsNotFound()
|
||||
{
|
||||
// Arrange
|
||||
var mockFileSystem = new MockFileSystem();
|
||||
var settingsUtils = new SettingsUtils(mockFileSystem);
|
||||
string file_name = "test\\Test Folder";
|
||||
string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
|
||||
|
||||
BasePTSettingsTest expected_json = JsonSerializer.Deserialize<BasePTSettingsTest>(file_contents_correct_json_content);
|
||||
|
||||
settingsUtils.SaveSettings(file_contents_correct_json_content, file_name);
|
||||
BasePTSettingsTest actual_json = settingsUtils.GetSettingsOrDefault<BasePTSettingsTest>(file_name);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expected_json.ToJsonString(), actual_json.ToJsonString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SettingsFolderExistsShouldReturnFalseWhenFilePathIsNotFound()
|
||||
{
|
||||
// Arrange
|
||||
var mockFileSystem = new MockFileSystem();
|
||||
var settingsUtils = new SettingsUtils(mockFileSystem);
|
||||
string file_name_random = "test\\" + RandomString();
|
||||
string file_name_exists = "test\\exists";
|
||||
string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
|
||||
|
||||
// Act
|
||||
bool pathNotFound = settingsUtils.SettingsExists(file_name_random);
|
||||
|
||||
settingsUtils.SaveSettings(file_contents_correct_json_content, file_name_exists);
|
||||
bool pathFound = settingsUtils.SettingsExists(file_name_exists);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(pathNotFound);
|
||||
Assert.IsTrue(pathFound);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SettingsUtilsMustReturnDefaultItemWhenFileIsCorrupt()
|
||||
{
|
||||
// Arrange
|
||||
var mockFileSystem = new MockFileSystem();
|
||||
var mockSettingsUtils = new SettingsUtils(mockFileSystem);
|
||||
|
||||
// Act
|
||||
TestClass settings = mockSettingsUtils.GetSettingsOrDefault<TestClass>(string.Empty);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(settings.TestInt, 100);
|
||||
Assert.AreEqual(settings.TestString, "test");
|
||||
}
|
||||
|
||||
public static string RandomString()
|
||||
{
|
||||
Random random = new Random();
|
||||
int length = 20;
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
return new string(Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
}
|
||||
|
||||
private partial class TestClass : ISettingsConfig
|
||||
{
|
||||
public int TestInt { get; set; } = 100;
|
||||
|
||||
public string TestString { get; set; } = "test";
|
||||
|
||||
public string GetModuleName()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
|
||||
public bool UpgradeSettingsConfiguration()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Platforms>x64</Platforms>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutputPath>..\..\..\x64\Debug\SettingsTests\</OutputPath>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutputPath>..\..\..\x64\Release\SettingsTest\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
<AdditionalFiles Include="..\..\codeAnalysis\StyleCop.json">
|
||||
<Link>StyleCop.json</Link>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
||||
<Version>3.3.0</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="12.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Settings.UI.Library\Settings.UI.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ColorPicker
|
||||
{
|
||||
/// <summary>
|
||||
/// Test if the original settings files were modified.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DataRow("v0.20.1", "settings.json")] // Color picker was introduced in .20
|
||||
[DataRow("v0.21.1", "settings.json")]
|
||||
[DataRow("v0.22.0", "settings.json")]
|
||||
public void OriginalFilesModificationTest(string version, string fileName)
|
||||
{
|
||||
// Arrange
|
||||
var mockIOProvider = BackCompatTestProperties.GetModuleIOProvider(version, ColorPickerSettings.ModuleName, fileName);
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
|
||||
var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object, settingPathMock.Object);
|
||||
ColorPickerSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault<ColorPickerSettings>(ColorPickerSettings.ModuleName);
|
||||
|
||||
var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
|
||||
// Act
|
||||
// Initialise View Model with test Config files
|
||||
using (var viewModel = new ColorPickerViewModel(mockSettingsUtils, generalSettingsRepository, ColorPickerIsEnabledByDefaultIPC))
|
||||
{
|
||||
// Assert
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.Enabled.ColorPicker, viewModel.IsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.ActivationShortcut.ToString(), viewModel.ActivationShortcut.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.ChangeCursor, viewModel.ChangeCursor);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyModuleIOProviderWasRead(mockIOProvider, ColorPickerSettings.ModuleName, expectedCallCount);
|
||||
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ColorPickerIsEnabledByDefault()
|
||||
{
|
||||
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ColorPickerSettings>();
|
||||
using (var viewModel = new ColorPickerViewModel(ISettingsUtilsMocks.GetStubSettingsUtils<ColorPickerSettings>().Object, SettingsRepository<GeneralSettings>.GetInstance(ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>().Object), ColorPickerIsEnabledByDefaultIPC))
|
||||
{
|
||||
Assert.IsTrue(viewModel.IsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
private static int ColorPickerIsEnabledByDefaultIPC(string msg)
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsTrue(snd.GeneralSettings.Enabled.ColorPicker);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,521 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class FancyZones
|
||||
{
|
||||
public const string FancyZonesTestFolderName = "Test\\FancyZones";
|
||||
|
||||
/// <summary>
|
||||
/// Test if the original settings files were modified.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DataRow("v0.18.2", "settings.json")]
|
||||
[DataRow("v0.19.2", "settings.json")]
|
||||
[DataRow("v0.20.1", "settings.json")]
|
||||
[DataRow("v0.21.1", "settings.json")]
|
||||
[DataRow("v0.22.0", "settings.json")]
|
||||
public void OriginalFilesModificationTest(string version, string fileName)
|
||||
{
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
|
||||
var fileMock = BackCompatTestProperties.GetModuleIOProvider(version, FancyZonesSettings.ModuleName, fileName);
|
||||
var mockSettingsUtils = new SettingsUtils(fileMock.Object, settingPathMock.Object);
|
||||
FancyZonesSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault<FancyZonesSettings>(FancyZonesSettings.ModuleName);
|
||||
|
||||
var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
var fancyZonesRepository = new BackCompatTestProperties.MockSettingsRepository<FancyZonesSettings>(mockSettingsUtils);
|
||||
|
||||
// Initialise View Model with test Config files
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils, generalSettingsRepository, fancyZonesRepository, ColorPickerIsEnabledByDefault_IPC);
|
||||
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.Enabled.FancyZones, viewModel.IsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesAppLastZoneMoveWindows.Value, viewModel.AppLastZoneMoveWindows);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesBorderColor.Value, viewModel.ZoneBorderColor);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesDisplayChangeMoveWindows.Value, viewModel.DisplayChangeMoveWindows);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesEditorHotkey.Value.ToString(), viewModel.EditorHotkey.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesWindowSwitching.Value, viewModel.WindowSwitching);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesNextTabHotkey.Value.ToString(), viewModel.NextTabHotkey.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesPrevTabHotkey.Value.ToString(), viewModel.PrevTabHotkey.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesExcludedApps.Value, viewModel.ExcludedApps);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesHighlightOpacity.Value, viewModel.HighlightOpacity);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesInActiveColor.Value, viewModel.ZoneInActiveColor);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesMakeDraggedWindowTransparent.Value, viewModel.MakeDraggedWindowsTransparent);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesMouseSwitch.Value, viewModel.MouseSwitch);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value, viewModel.MoveWindowsAcrossMonitors);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value, viewModel.MoveWindowsBasedOnPosition);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value, viewModel.OpenWindowOnActiveMonitor);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesOverrideSnapHotkeys.Value, viewModel.OverrideSnapHotkeys);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesRestoreSize.Value, viewModel.RestoreSize);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesShiftDrag.Value, viewModel.ShiftDrag);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesShowOnAllMonitors.Value, viewModel.ShowOnAllMonitors);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesSpanZonesAcrossMonitors.Value, viewModel.SpanZonesAcrossMonitors);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesZoneHighlightColor.Value, viewModel.ZoneHighlightColor);
|
||||
Assert.AreEqual(originalSettings.Properties.FancyzonesZoneSetChangeMoveWindows.Value, viewModel.ZoneSetChangeMoveWindows);
|
||||
Assert.AreEqual(originalSettings.Properties.UseCursorposEditorStartupscreen.Value, viewModel.UseCursorPosEditorStartupScreen);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyModuleIOProviderWasRead(fileMock, FancyZonesSettings.ModuleName, expectedCallCount);
|
||||
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount);
|
||||
}
|
||||
|
||||
private int ColorPickerIsEnabledByDefault_IPC(string msg)
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsTrue(snd.GeneralSettings.Enabled.ColorPicker);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private Mock<ISettingsUtils> mockGeneralSettingsUtils;
|
||||
|
||||
private Mock<ISettingsUtils> mockFancyZonesSettingsUtils;
|
||||
|
||||
private Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUpStubSettingUtils()
|
||||
{
|
||||
mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
mockFancyZonesSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<FancyZonesSettings>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsEnabledShouldDisableModuleWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsFalse(snd.GeneralSettings.Enabled.FancyZones);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsTrue(viewModel.IsEnabled); // check if the module is enabled.
|
||||
|
||||
// act
|
||||
viewModel.IsEnabled = false;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ShiftDragShouldSetValue2FalseWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsTrue(viewModel.ShiftDrag); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.ShiftDrag = false;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.ShiftDrag;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesShiftDrag.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OverrideSnapHotkeysShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.OverrideSnapHotkeys); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.OverrideSnapHotkeys = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.OverrideSnapHotkeys;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesOverrideSnapHotkeys.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MoveWindowsAcrossMonitorsShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.MoveWindowsAcrossMonitors); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.MoveWindowsAcrossMonitors = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.MoveWindowsAcrossMonitors;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesMoveWindowsAcrossMonitors.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MoveWindowsBasedOnPositionShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.MoveWindowsBasedOnPosition); // check if value was initialized to false.
|
||||
Assert.IsTrue(viewModel.MoveWindowsBasedOnZoneIndex); // check if value was initialized to true.
|
||||
|
||||
// act
|
||||
viewModel.MoveWindowsBasedOnPosition = true;
|
||||
|
||||
// assert
|
||||
var basedOnPositionExpected = viewModel.MoveWindowsBasedOnPosition;
|
||||
var basedOnPositionActual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesMoveWindowsBasedOnPosition.Value;
|
||||
Assert.AreEqual(basedOnPositionExpected, basedOnPositionActual);
|
||||
|
||||
var basedOnZoneIndexExpected = viewModel.MoveWindowsBasedOnZoneIndex;
|
||||
var basedOnZoneIndexActual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesMoveWindowsBasedOnPosition.Value;
|
||||
Assert.AreNotEqual(basedOnZoneIndexExpected, basedOnZoneIndexActual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void QuickLayoutSwitchShouldSetValue2FalseWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsTrue(viewModel.QuickLayoutSwitch); // check if value was initialized to true.
|
||||
|
||||
// act
|
||||
viewModel.QuickLayoutSwitch = false;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.QuickLayoutSwitch;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesQuickLayoutSwitch.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FlashZonesOnQuickSwitchShouldSetValue2FalseWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsTrue(viewModel.FlashZonesOnQuickSwitch); // check if value was initialized to true.
|
||||
|
||||
// act
|
||||
viewModel.FlashZonesOnQuickSwitch = false;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.FlashZonesOnQuickSwitch;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesFlashZonesOnQuickSwitch.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MakeDraggedWindowsTransparentShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.MakeDraggedWindowsTransparent); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.MakeDraggedWindowsTransparent = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.MakeDraggedWindowsTransparent;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesMakeDraggedWindowTransparent.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MouseSwitchShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.MouseSwitch); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.MouseSwitch = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.MouseSwitch;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesMouseSwitch.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DisplayChangeMoveWindowsShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.DisplayChangeMoveWindows); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.DisplayChangeMoveWindows = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.DisplayChangeMoveWindows;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesDisplayChangeMoveWindows.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ZoneSetChangeMoveWindowsShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.ZoneSetChangeMoveWindows); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.ZoneSetChangeMoveWindows = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.ZoneSetChangeMoveWindows;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AppLastZoneMoveWindowsShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.AppLastZoneMoveWindows); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.AppLastZoneMoveWindows = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.AppLastZoneMoveWindows;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesAppLastZoneMoveWindows.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OpenWindowOnActiveMonitorShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.OpenWindowOnActiveMonitor); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.OpenWindowOnActiveMonitor = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.OpenWindowOnActiveMonitor;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesOpenWindowOnActiveMonitor.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RestoreSizeShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.RestoreSize); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.RestoreSize = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.RestoreSize;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesRestoreSize.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UseCursorPosEditorStartupScreenShouldSetValue2FalseWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsTrue(viewModel.UseCursorPosEditorStartupScreen); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.UseCursorPosEditorStartupScreen = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.UseCursorPosEditorStartupScreen;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.UseCursorposEditorStartupscreen.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ShowOnAllMonitorsShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.ShowOnAllMonitors); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.ShowOnAllMonitors = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.ShowOnAllMonitors;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesShowOnAllMonitors.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SpanZonesAcrossMonitorsShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.IsFalse(viewModel.SpanZonesAcrossMonitors); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.SpanZonesAcrossMonitors = true;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.SpanZonesAcrossMonitors;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesSpanZonesAcrossMonitors.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OverlappingZonesAlgorithmIndexShouldSetValue2AnotherWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.AreEqual(0, viewModel.OverlappingZonesAlgorithmIndex); // check if value was initialized to false.
|
||||
|
||||
// act
|
||||
viewModel.OverlappingZonesAlgorithmIndex = 1;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.OverlappingZonesAlgorithmIndex;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesOverlappingZonesAlgorithm.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ZoneHighlightColorShouldSetColorValue2WhiteWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.AreEqual(ConfigDefaults.DefaultFancyZonesZoneHighlightColor, viewModel.ZoneHighlightColor);
|
||||
|
||||
// act
|
||||
viewModel.ZoneHighlightColor = "#FFFFFF";
|
||||
|
||||
// assert
|
||||
var expected = viewModel.ZoneHighlightColor;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesZoneHighlightColor.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ZoneBorderColorShouldSetColorValue2WhiteWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.AreEqual(ConfigDefaults.DefaultFancyzonesBorderColor, viewModel.ZoneBorderColor);
|
||||
|
||||
// act
|
||||
viewModel.ZoneBorderColor = "#FFFFFF";
|
||||
|
||||
// assert
|
||||
var expected = viewModel.ZoneBorderColor;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesBorderColor.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ZoneInActiveColorShouldSetColorValue2WhiteWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.AreEqual(ConfigDefaults.DefaultFancyZonesInActiveColor, viewModel.ZoneInActiveColor);
|
||||
|
||||
// act
|
||||
viewModel.ZoneInActiveColor = "#FFFFFF";
|
||||
|
||||
// assert
|
||||
var expected = viewModel.ZoneInActiveColor;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesInActiveColor.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExcludedAppsShouldSetColorValue2WhiteWhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.AreEqual(string.Empty, viewModel.ExcludedApps);
|
||||
|
||||
// act
|
||||
viewModel.ExcludedApps = "Sample";
|
||||
|
||||
// assert
|
||||
var expected = viewModel.ExcludedApps;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesExcludedApps.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HighlightOpacityShouldSetOpacityValueTo60WhenSuccessful()
|
||||
{
|
||||
Mock<SettingsUtils> mockSettingsUtils = new Mock<SettingsUtils>();
|
||||
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object), sendMockIPCConfigMSG, FancyZonesTestFolderName);
|
||||
Assert.AreEqual(50, viewModel.HighlightOpacity);
|
||||
|
||||
// act
|
||||
viewModel.HighlightOpacity = 60;
|
||||
|
||||
// assert
|
||||
var expected = viewModel.HighlightOpacity;
|
||||
var actual = SettingsRepository<FancyZonesSettings>.GetInstance(mockFancyZonesSettingsUtils.Object).SettingsConfig.Properties.FancyzonesHighlightOpacity.Value;
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
253
src/settings-ui/Settings.UI.UnitTests/ViewModelTests/General.cs
Normal file
253
src/settings-ui/Settings.UI.UnitTests/ViewModelTests/General.cs
Normal file
@@ -0,0 +1,253 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class General
|
||||
{
|
||||
public const string GeneralSettingsFileName = "Test\\GeneralSettings";
|
||||
|
||||
private Mock<ISettingsUtils> mockGeneralSettingsUtils;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUpStubSettingUtils()
|
||||
{
|
||||
mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("v0.18.2")]
|
||||
[DataRow("v0.19.2")]
|
||||
[DataRow("v0.20.1")]
|
||||
[DataRow("v0.21.1")]
|
||||
[DataRow("v0.22.0")]
|
||||
public void OriginalFilesModificationTest(string version)
|
||||
{
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
var fileMock = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(fileMock.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
|
||||
// Initialise View Model with test Config files
|
||||
// Arrange
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => 0;
|
||||
Func<string, int> sendRestartAdminIPCMessage = msg => 0;
|
||||
Func<string, int> sendCheckForUpdatesIPCMessage = msg => 0;
|
||||
var viewModel = new GeneralViewModel(
|
||||
settingsRepository: generalSettingsRepository,
|
||||
runAsAdminText: "GeneralSettings_RunningAsAdminText",
|
||||
runAsUserText: "GeneralSettings_RunningAsUserText",
|
||||
isElevated: false,
|
||||
isAdmin: false,
|
||||
updateTheme: UpdateUIThemeMethod,
|
||||
ipcMSGCallBackFunc: sendMockIPCConfigMSG,
|
||||
ipcMSGRestartAsAdminMSGCallBackFunc: sendRestartAdminIPCMessage,
|
||||
ipcMSGCheckForUpdatesCallBackFunc: sendCheckForUpdatesIPCMessage,
|
||||
configFileSubfolder: string.Empty);
|
||||
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.AutoDownloadUpdates, viewModel.AutoDownloadUpdates);
|
||||
Assert.AreEqual(originalGeneralSettings.PowertoysVersion, viewModel.PowerToysVersion);
|
||||
Assert.AreEqual(originalGeneralSettings.RunElevated, viewModel.RunElevated);
|
||||
Assert.AreEqual(originalGeneralSettings.Startup, viewModel.Startup);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(fileMock, expectedCallCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsElevatedShouldUpdateRunasAdminStatusAttrsWhenSuccessful()
|
||||
{
|
||||
// Arrange
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
Func<string, int> sendRestartAdminIPCMessage = msg => { return 0; };
|
||||
Func<string, int> sendCheckForUpdatesIPCMessage = msg => { return 0; };
|
||||
GeneralViewModel viewModel = new GeneralViewModel(
|
||||
settingsRepository: SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object),
|
||||
"GeneralSettings_RunningAsAdminText",
|
||||
"GeneralSettings_RunningAsUserText",
|
||||
false,
|
||||
false,
|
||||
UpdateUIThemeMethod,
|
||||
sendMockIPCConfigMSG,
|
||||
sendRestartAdminIPCMessage,
|
||||
sendCheckForUpdatesIPCMessage,
|
||||
GeneralSettingsFileName);
|
||||
|
||||
Assert.AreEqual(viewModel.RunningAsUserDefaultText, viewModel.RunningAsText);
|
||||
Assert.IsFalse(viewModel.IsElevated);
|
||||
|
||||
// Act
|
||||
viewModel.IsElevated = true;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(viewModel.RunningAsAdminDefaultText, viewModel.RunningAsText);
|
||||
Assert.IsTrue(viewModel.IsElevated);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void StartupShouldEnableRunOnStartUpWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsTrue(snd.GeneralSettings.Startup);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// Arrange
|
||||
Func<string, int> sendRestartAdminIPCMessage = msg => { return 0; };
|
||||
Func<string, int> sendCheckForUpdatesIPCMessage = msg => { return 0; };
|
||||
GeneralViewModel viewModel = new GeneralViewModel(
|
||||
settingsRepository: SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object),
|
||||
"GeneralSettings_RunningAsAdminText",
|
||||
"GeneralSettings_RunningAsUserText",
|
||||
false,
|
||||
false,
|
||||
UpdateUIThemeMethod,
|
||||
sendMockIPCConfigMSG,
|
||||
sendRestartAdminIPCMessage,
|
||||
sendCheckForUpdatesIPCMessage,
|
||||
GeneralSettingsFileName);
|
||||
Assert.IsFalse(viewModel.Startup);
|
||||
|
||||
// act
|
||||
viewModel.Startup = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RunElevatedShouldEnableAlwaysRunElevatedWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsTrue(snd.GeneralSettings.RunElevated);
|
||||
return 0;
|
||||
};
|
||||
|
||||
Func<string, int> sendRestartAdminIPCMessage = msg => { return 0; };
|
||||
Func<string, int> sendCheckForUpdatesIPCMessage = msg => { return 0; };
|
||||
|
||||
// Arrange
|
||||
GeneralViewModel viewModel = new GeneralViewModel(
|
||||
settingsRepository: SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object),
|
||||
"GeneralSettings_RunningAsAdminText",
|
||||
"GeneralSettings_RunningAsUserText",
|
||||
false,
|
||||
false,
|
||||
UpdateUIThemeMethod,
|
||||
sendMockIPCConfigMSG,
|
||||
sendRestartAdminIPCMessage,
|
||||
sendCheckForUpdatesIPCMessage,
|
||||
GeneralSettingsFileName);
|
||||
|
||||
Assert.IsFalse(viewModel.RunElevated);
|
||||
|
||||
// act
|
||||
viewModel.RunElevated = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsLightThemeRadioButtonCheckedShouldThemeToLightWhenSuccessful()
|
||||
{
|
||||
// Arrange
|
||||
GeneralViewModel viewModel = null;
|
||||
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.AreEqual("light", snd.GeneralSettings.Theme);
|
||||
return 0;
|
||||
};
|
||||
|
||||
Func<string, int> sendRestartAdminIPCMessage = msg => { return 0; };
|
||||
Func<string, int> sendCheckForUpdatesIPCMessage = msg => { return 0; };
|
||||
viewModel = new GeneralViewModel(
|
||||
settingsRepository: SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object),
|
||||
"GeneralSettings_RunningAsAdminText",
|
||||
"GeneralSettings_RunningAsUserText",
|
||||
false,
|
||||
false,
|
||||
UpdateUIThemeMethod,
|
||||
sendMockIPCConfigMSG,
|
||||
sendRestartAdminIPCMessage,
|
||||
sendCheckForUpdatesIPCMessage,
|
||||
GeneralSettingsFileName);
|
||||
Assert.AreNotEqual(1, viewModel.ThemeIndex);
|
||||
|
||||
// act
|
||||
viewModel.ThemeIndex = 1;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsDarkThemeRadioButtonCheckedShouldThemeToDarkWhenSuccessful()
|
||||
{
|
||||
// Arrange
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.AreEqual("dark", snd.GeneralSettings.Theme);
|
||||
return 0;
|
||||
};
|
||||
|
||||
Func<string, int> sendRestartAdminIPCMessage = msg => { return 0; };
|
||||
Func<string, int> sendCheckForUpdatesIPCMessage = msg => { return 0; };
|
||||
GeneralViewModel viewModel = new GeneralViewModel(
|
||||
settingsRepository: SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object),
|
||||
"GeneralSettings_RunningAsAdminText",
|
||||
"GeneralSettings_RunningAsUserText",
|
||||
false,
|
||||
false,
|
||||
UpdateUIThemeMethod,
|
||||
sendMockIPCConfigMSG,
|
||||
sendRestartAdminIPCMessage,
|
||||
sendCheckForUpdatesIPCMessage,
|
||||
GeneralSettingsFileName);
|
||||
Assert.AreNotEqual(0, viewModel.ThemeIndex);
|
||||
|
||||
// act
|
||||
viewModel.ThemeIndex = 0;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AllModulesAreEnabledByDefault()
|
||||
{
|
||||
// arrange
|
||||
EnabledModules modules = new EnabledModules();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(modules.FancyZones);
|
||||
Assert.IsTrue(modules.ImageResizer);
|
||||
Assert.IsTrue(modules.FileExplorerPreview);
|
||||
Assert.IsTrue(modules.ShortcutGuide);
|
||||
Assert.IsTrue(modules.PowerRename);
|
||||
Assert.IsTrue(modules.KeyboardManager);
|
||||
Assert.IsTrue(modules.PowerLauncher);
|
||||
Assert.IsTrue(modules.ColorPicker);
|
||||
}
|
||||
|
||||
public static int UpdateUIThemeMethod(string themeName)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ImageResizer
|
||||
{
|
||||
private Mock<ISettingsUtils> _mockGeneralSettingsUtils;
|
||||
|
||||
private Mock<ISettingsUtils> _mockImgResizerSettingsUtils;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUpStubSettingUtils()
|
||||
{
|
||||
_mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
_mockImgResizerSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if the original settings files were modified.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DataRow("v0.18.2", "settings.json")]
|
||||
[DataRow("v0.19.2", "settings.json")]
|
||||
[DataRow("v0.20.1", "settings.json")]
|
||||
[DataRow("v0.21.1", "settings.json")]
|
||||
[DataRow("v0.22.0", "settings.json")]
|
||||
public void OriginalFilesModificationTest(string version, string fileName)
|
||||
{
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
|
||||
var fileMock = BackCompatTestProperties.GetModuleIOProvider(version, ImageResizerSettings.ModuleName, fileName);
|
||||
var mockSettingsUtils = new SettingsUtils(fileMock.Object, settingPathMock.Object);
|
||||
|
||||
ImageResizerSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault<ImageResizerSettings>(ImageResizerSettings.ModuleName);
|
||||
|
||||
var mockGeneralFileMock = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralFileMock.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
|
||||
// Initialise View Model with test Config files
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, generalSettingsRepository, sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.Enabled.ImageResizer, viewModel.IsEnabled);
|
||||
Assert.AreEqual(ImageResizerViewModel.GetEncoderIndex(originalSettings.Properties.ImageresizerFallbackEncoder.Value), viewModel.Encoder);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerFileName.Value, viewModel.FileName);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerJpegQualityLevel.Value, viewModel.JPEGQualityLevel);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerKeepDateModified.Value, viewModel.KeepDateModified);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerPngInterlaceOption.Value, viewModel.PngInterlaceOption);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerSizes.Value.Count, viewModel.Sizes.Count);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerTiffCompressOption.Value, viewModel.TiffCompressOption);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyModuleIOProviderWasRead(fileMock, ImageResizerSettings.ModuleName, expectedCallCount);
|
||||
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralFileMock, expectedCallCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsEnabledShouldEnableModuleWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsTrue(snd.GeneralSettings.Enabled.ImageResizer);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(_mockImgResizerSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.IsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void JPEGQualityLevelShouldSetValueToTenWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var fileSystemMock = new MockFileSystem();
|
||||
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.JPEGQualityLevel = 10;
|
||||
|
||||
// Assert
|
||||
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
Assert.AreEqual(10, viewModel.JPEGQualityLevel);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PngInterlaceOptionShouldSetValueToTenWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var fileSystemMock = new MockFileSystem();
|
||||
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.PngInterlaceOption = 10;
|
||||
|
||||
// Assert
|
||||
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
Assert.AreEqual(10, viewModel.PngInterlaceOption);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TiffCompressOptionShouldSetValueToTenWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var fileSystemMock = new MockFileSystem();
|
||||
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.TiffCompressOption = 10;
|
||||
|
||||
// Assert
|
||||
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
Assert.AreEqual(10, viewModel.TiffCompressOption);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FileNameShouldUpdateValueWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var fileSystemMock = new MockFileSystem();
|
||||
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
string expectedValue = "%1 (%3)";
|
||||
|
||||
// act
|
||||
viewModel.FileName = expectedValue;
|
||||
|
||||
// Assert
|
||||
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
Assert.AreEqual(expectedValue, viewModel.FileName);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void KeepDateModifiedShouldUpdateValueWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var settingUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
||||
|
||||
var expectedSettingsString = new ImageResizerSettings() { Properties = new ImageResizerProperties() { ImageresizerKeepDateModified = new BoolProperty() { Value = true } } }.ToJsonString();
|
||||
|
||||
// Using Ordinal since this is used internally
|
||||
settingUtils.Setup(x => x.SaveSettings(
|
||||
It.Is<string>(content => content.Equals(expectedSettingsString, StringComparison.Ordinal)),
|
||||
It.Is<string>(module => module.Equals(ImageResizerSettings.ModuleName, StringComparison.Ordinal)),
|
||||
It.IsAny<string>()))
|
||||
.Verifiable();
|
||||
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(settingUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.KeepDateModified = true;
|
||||
|
||||
// Assert
|
||||
settingUtils.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EncoderShouldUpdateValueWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var fileSystemMock = new MockFileSystem();
|
||||
var mockSettingsUtils = new SettingsUtils(fileSystemMock);
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.Encoder = 3;
|
||||
|
||||
// Assert
|
||||
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.EncoderGuid);
|
||||
Assert.AreEqual(3, viewModel.Encoder);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddRowShouldAddNewImageSizeWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
int sizeOfOriginalArray = viewModel.Sizes.Count;
|
||||
|
||||
// act
|
||||
viewModel.AddRow("New size");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(sizeOfOriginalArray + 1, viewModel.Sizes.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NewlyAddedImageSizeHasCorrectValues()
|
||||
{
|
||||
// arrange
|
||||
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.AddRow("New size");
|
||||
|
||||
// Assert
|
||||
ImageSize newTestSize = viewModel.Sizes.Where<ImageSize>(x => x.Id == 0).First();
|
||||
Assert.AreEqual(newTestSize.Name, "New size 1");
|
||||
Assert.AreEqual(newTestSize.Fit, (int)ResizeFit.Fit);
|
||||
Assert.AreEqual(newTestSize.Width, 854);
|
||||
Assert.AreEqual(newTestSize.Height, 480);
|
||||
Assert.AreEqual(newTestSize.Unit, (int)ResizeUnit.Pixel);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DeleteImageSizeShouldDeleteImageSizeWhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
viewModel.AddRow("New Size");
|
||||
int sizeOfOriginalArray = viewModel.Sizes.Count;
|
||||
ImageSize deleteCandidate = viewModel.Sizes.Where<ImageSize>(x => x.Id == 0).First();
|
||||
|
||||
// act
|
||||
viewModel.DeleteImageSize(0);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(sizeOfOriginalArray - 1, viewModel.Sizes.Count);
|
||||
Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NameOfNewImageSizesIsIncrementedCorrectly()
|
||||
{
|
||||
// arrange
|
||||
var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ImageResizerSettings>();
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ImageResizerViewModel viewModel = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
|
||||
|
||||
// act
|
||||
viewModel.AddRow("New size"); // Add: "New size 1"
|
||||
viewModel.AddRow("New size"); // Add: "New size 2"
|
||||
viewModel.AddRow("New size"); // Add: "New size 3"
|
||||
viewModel.DeleteImageSize(1); // Delete: "New size 2"
|
||||
viewModel.AddRow("New size"); // Add: "New Size 4"
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(viewModel.Sizes[0].Name, "New size 1");
|
||||
Assert.AreEqual(viewModel.Sizes[1].Name, "New size 3");
|
||||
Assert.AreEqual(viewModel.Sizes[2].Name, "New size 4");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateWidthAndHeightShouldUpdateSizeWhenCorrectValuesAreProvided()
|
||||
{
|
||||
// arrange
|
||||
ImageSize imageSize = new ImageSize()
|
||||
{
|
||||
Id = 0,
|
||||
Name = "Test",
|
||||
Fit = (int)ResizeFit.Fit,
|
||||
Width = 30,
|
||||
Height = 30,
|
||||
Unit = (int)ResizeUnit.Pixel,
|
||||
};
|
||||
|
||||
double negativeWidth = -2.0;
|
||||
double negativeHeight = -2.0;
|
||||
|
||||
// Act
|
||||
imageSize.Width = negativeWidth;
|
||||
imageSize.Height = negativeHeight;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(0, imageSize.Width);
|
||||
Assert.AreEqual(0, imageSize.Height);
|
||||
|
||||
// Act
|
||||
imageSize.Width = 50;
|
||||
imageSize.Height = 50;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(50, imageSize.Width);
|
||||
Assert.AreEqual(50, imageSize.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class KeyboardManager
|
||||
{
|
||||
public const string Module = KeyboardManagerSettings.ModuleName;
|
||||
|
||||
[TestInitialize]
|
||||
public void Setup()
|
||||
{
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void CleanUp()
|
||||
{
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CombineShortcutListsShouldReturnEmptyListWhenBothArgumentsAreEmptyLists()
|
||||
{
|
||||
// arrange
|
||||
var firstList = new List<KeysDataModel>();
|
||||
var secondList = new List<AppSpecificKeysDataModel>();
|
||||
|
||||
// act
|
||||
var result = KeyboardManagerViewModel.CombineShortcutLists(firstList, secondList);
|
||||
|
||||
// Assert
|
||||
var expectedResult = new List<AppSpecificKeysDataModel>();
|
||||
|
||||
Assert.AreEqual(expectedResult.Count, result.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CombineShortcutListsShouldReturnEmptyListWhenBothArgumentsAreNull()
|
||||
{
|
||||
// act
|
||||
var result = KeyboardManagerViewModel.CombineShortcutLists(null, null);
|
||||
|
||||
// Assert
|
||||
var expectedResult = new List<AppSpecificKeysDataModel>();
|
||||
|
||||
Assert.AreEqual(expectedResult.Count, result.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CombineShortcutListsShouldReturnListWithOneAppSpecificEntryWhenFirstArgumentIsNullAndSecondArgumentHasOneEntry()
|
||||
{
|
||||
// arrange
|
||||
var secondList = new List<AppSpecificKeysDataModel>();
|
||||
var entry = new AppSpecificKeysDataModel();
|
||||
entry.OriginalKeys = "17;65";
|
||||
entry.NewRemapKeys = "17;86";
|
||||
entry.TargetApp = "msedge";
|
||||
secondList.Add(entry);
|
||||
|
||||
// act
|
||||
var result = KeyboardManagerViewModel.CombineShortcutLists(null, secondList);
|
||||
|
||||
// Assert
|
||||
var expectedResult = new List<AppSpecificKeysDataModel>();
|
||||
var expectedEntry = new AppSpecificKeysDataModel();
|
||||
expectedEntry.OriginalKeys = entry.OriginalKeys;
|
||||
expectedEntry.NewRemapKeys = entry.NewRemapKeys;
|
||||
expectedEntry.TargetApp = entry.TargetApp;
|
||||
expectedResult.Add(expectedEntry);
|
||||
|
||||
Assert.AreEqual(expectedResult.Count, result.Count);
|
||||
Assert.IsTrue(expectedResult[0].Compare(result[0]));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CombineShortcutListsShouldReturnListWithOneAllAppsEntryWhenFirstArgumentHasOneEntryAndSecondArgumentIsNull()
|
||||
{
|
||||
// arrange
|
||||
var firstList = new List<KeysDataModel>();
|
||||
var entry = new KeysDataModel();
|
||||
entry.OriginalKeys = "17;65";
|
||||
entry.NewRemapKeys = "17;86";
|
||||
firstList.Add(entry);
|
||||
|
||||
// act
|
||||
var result = KeyboardManagerViewModel.CombineShortcutLists(firstList, null);
|
||||
|
||||
// Assert
|
||||
var expectedResult = new List<AppSpecificKeysDataModel>();
|
||||
var expectedEntry = new AppSpecificKeysDataModel();
|
||||
expectedEntry.OriginalKeys = entry.OriginalKeys;
|
||||
expectedEntry.NewRemapKeys = entry.NewRemapKeys;
|
||||
expectedEntry.TargetApp = "All Apps";
|
||||
expectedResult.Add(expectedEntry);
|
||||
|
||||
Assert.AreEqual(expectedResult.Count, result.Count);
|
||||
Assert.IsTrue(expectedResult[0].Compare(result[0]));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CombineShortcutListsShouldReturnListWithOneAllAppsEntryWhenFirstArgumentHasOneEntryAndSecondArgumentIsEmpty()
|
||||
{
|
||||
// arrange
|
||||
var firstList = new List<KeysDataModel>();
|
||||
var entry = new KeysDataModel();
|
||||
entry.OriginalKeys = "17;65";
|
||||
entry.NewRemapKeys = "17;86";
|
||||
firstList.Add(entry);
|
||||
var secondList = new List<AppSpecificKeysDataModel>();
|
||||
|
||||
// act
|
||||
var result = KeyboardManagerViewModel.CombineShortcutLists(firstList, secondList);
|
||||
|
||||
// Assert
|
||||
var expectedResult = new List<AppSpecificKeysDataModel>();
|
||||
var expectedEntry = new AppSpecificKeysDataModel();
|
||||
expectedEntry.OriginalKeys = entry.OriginalKeys;
|
||||
expectedEntry.NewRemapKeys = entry.NewRemapKeys;
|
||||
expectedEntry.TargetApp = "All Apps";
|
||||
expectedResult.Add(expectedEntry);
|
||||
var x = expectedResult[0].Equals(result[0]);
|
||||
Assert.AreEqual(expectedResult.Count, result.Count);
|
||||
Assert.IsTrue(expectedResult[0].Compare(result[0]));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CombineShortcutListsShouldReturnListWithOneAppSpecificEntryWhenFirstArgumentIsEmptyAndSecondArgumentHasOneEntry()
|
||||
{
|
||||
// arrange
|
||||
var firstList = new List<KeysDataModel>();
|
||||
var secondList = new List<AppSpecificKeysDataModel>();
|
||||
var entry = new AppSpecificKeysDataModel();
|
||||
entry.OriginalKeys = "17;65";
|
||||
entry.NewRemapKeys = "17;86";
|
||||
entry.TargetApp = "msedge";
|
||||
secondList.Add(entry);
|
||||
|
||||
// act
|
||||
var result = KeyboardManagerViewModel.CombineShortcutLists(firstList, secondList);
|
||||
|
||||
// Assert
|
||||
var expectedResult = new List<AppSpecificKeysDataModel>();
|
||||
var expectedEntry = new AppSpecificKeysDataModel();
|
||||
expectedEntry.OriginalKeys = entry.OriginalKeys;
|
||||
expectedEntry.NewRemapKeys = entry.NewRemapKeys;
|
||||
expectedEntry.TargetApp = entry.TargetApp;
|
||||
expectedResult.Add(expectedEntry);
|
||||
|
||||
Assert.AreEqual(expectedResult.Count, result.Count);
|
||||
Assert.IsTrue(expectedResult[0].Compare(result[0]));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CombineShortcutListsShouldReturnListWithOneAllAppsEntryAndOneAppSpecificEntryWhenFirstArgumentHasOneEntryAndSecondArgumentHasOneEntry()
|
||||
{
|
||||
// arrange
|
||||
var firstList = new List<KeysDataModel>();
|
||||
var firstListEntry = new KeysDataModel();
|
||||
firstListEntry.OriginalKeys = "17;65";
|
||||
firstListEntry.NewRemapKeys = "17;86";
|
||||
firstList.Add(firstListEntry);
|
||||
var secondList = new List<AppSpecificKeysDataModel>();
|
||||
var secondListEntry = new AppSpecificKeysDataModel();
|
||||
secondListEntry.OriginalKeys = "17;66";
|
||||
secondListEntry.NewRemapKeys = "17;87";
|
||||
secondListEntry.TargetApp = "msedge";
|
||||
secondList.Add(secondListEntry);
|
||||
|
||||
// act
|
||||
var result = KeyboardManagerViewModel.CombineShortcutLists(firstList, secondList);
|
||||
|
||||
// Assert
|
||||
var expectedResult = new List<AppSpecificKeysDataModel>();
|
||||
var expectedFirstEntry = new AppSpecificKeysDataModel();
|
||||
expectedFirstEntry.OriginalKeys = firstListEntry.OriginalKeys;
|
||||
expectedFirstEntry.NewRemapKeys = firstListEntry.NewRemapKeys;
|
||||
expectedFirstEntry.TargetApp = "All Apps";
|
||||
expectedResult.Add(expectedFirstEntry);
|
||||
var expectedSecondEntry = new AppSpecificKeysDataModel();
|
||||
expectedSecondEntry.OriginalKeys = secondListEntry.OriginalKeys;
|
||||
expectedSecondEntry.NewRemapKeys = secondListEntry.NewRemapKeys;
|
||||
expectedSecondEntry.TargetApp = secondListEntry.TargetApp;
|
||||
expectedResult.Add(expectedSecondEntry);
|
||||
|
||||
Assert.AreEqual(expectedResult.Count, result.Count);
|
||||
Assert.IsTrue(expectedResult[0].Compare(result[0]));
|
||||
Assert.IsTrue(expectedResult[1].Compare(result[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class PowerLauncherViewModelTest
|
||||
{
|
||||
private class SendCallbackMock
|
||||
{
|
||||
public int TimesSent { get; set; }
|
||||
|
||||
// PowerLauncherSettings is unused, but required according to SendCallback's signature.
|
||||
// Naming parameter with discard symbol to suppress FxCop warnings.
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "We actually don't validate setting, just calculate it was sent")]
|
||||
public void OnSend(PowerLauncherSettings _)
|
||||
{
|
||||
TimesSent++;
|
||||
}
|
||||
}
|
||||
|
||||
private PowerLauncherViewModel viewModel;
|
||||
private PowerLauncherSettings mockSettings;
|
||||
private SendCallbackMock sendCallbackMock;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
mockSettings = new PowerLauncherSettings();
|
||||
sendCallbackMock = new SendCallbackMock();
|
||||
viewModel = new PowerLauncherViewModel(
|
||||
mockSettings,
|
||||
new PowerLauncherViewModel.SendCallback(sendCallbackMock.OnSend));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if the original settings files were modified.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DataRow("v0.18.2", "settings.json")]
|
||||
[DataRow("v0.19.2", "settings.json")]
|
||||
[DataRow("v0.20.1", "settings.json")]
|
||||
[DataRow("v0.21.1", "settings.json")]
|
||||
[DataRow("v0.22.0", "settings.json")]
|
||||
public void OriginalFilesModificationTest(string version, string fileName)
|
||||
{
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
|
||||
var mockIOProvider = BackCompatTestProperties.GetModuleIOProvider(version, PowerLauncherSettings.ModuleName, fileName);
|
||||
var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object, settingPathMock.Object);
|
||||
PowerLauncherSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
|
||||
|
||||
var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
|
||||
// Initialise View Model with test Config files
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
PowerLauncherViewModel viewModel = new PowerLauncherViewModel(originalSettings, generalSettingsRepository, sendMockIPCConfigMSG, () => true);
|
||||
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.Enabled.PowerLauncher, viewModel.EnablePowerLauncher);
|
||||
Assert.AreEqual(originalSettings.Properties.ClearInputOnLaunch, viewModel.ClearInputOnLaunch);
|
||||
Assert.AreEqual(originalSettings.Properties.CopyPathLocation.ToString(), viewModel.CopyPathLocation.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.IgnoreHotkeysInFullscreen, viewModel.IgnoreHotkeysInFullScreen);
|
||||
Assert.AreEqual(originalSettings.Properties.MaximumNumberOfResults, viewModel.MaximumNumberOfResults);
|
||||
Assert.AreEqual(originalSettings.Properties.OpenPowerLauncher.ToString(), viewModel.OpenPowerLauncher.ToString());
|
||||
Assert.AreEqual(originalSettings.Properties.OverrideWinkeyR, viewModel.OverrideWinRKey);
|
||||
Assert.AreEqual(originalSettings.Properties.OverrideWinkeyS, viewModel.OverrideWinSKey);
|
||||
Assert.AreEqual(originalSettings.Properties.SearchResultPreference, viewModel.SearchResultPreference);
|
||||
Assert.AreEqual(originalSettings.Properties.SearchTypePreference, viewModel.SearchTypePreference);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SearchPreferenceShouldUpdatePreferences()
|
||||
{
|
||||
viewModel.SearchResultPreference = "SearchOptionsAreNotValidated";
|
||||
viewModel.SearchTypePreference = "SearchOptionsAreNotValidated";
|
||||
|
||||
Assert.AreEqual(sendCallbackMock.TimesSent, 2);
|
||||
Assert.IsTrue(mockSettings.Properties.SearchResultPreference == "SearchOptionsAreNotValidated");
|
||||
Assert.IsTrue(mockSettings.Properties.SearchTypePreference == "SearchOptionsAreNotValidated");
|
||||
}
|
||||
|
||||
public static void AssertHotkeySettings(HotkeySettings setting, bool win, bool ctrl, bool alt, bool shift, int code)
|
||||
{
|
||||
if (setting != null)
|
||||
{
|
||||
Assert.AreEqual(win, setting.Win);
|
||||
Assert.AreEqual(ctrl, setting.Ctrl);
|
||||
Assert.AreEqual(alt, setting.Alt);
|
||||
Assert.AreEqual(shift, setting.Shift);
|
||||
Assert.AreEqual(code, setting.Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail("setting parameter is null");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HotkeysShouldUpdateHotkeys()
|
||||
{
|
||||
var openPowerLauncher = new HotkeySettings();
|
||||
openPowerLauncher.Win = true;
|
||||
openPowerLauncher.Code = 83;
|
||||
|
||||
var openFileLocation = new HotkeySettings();
|
||||
openFileLocation.Ctrl = true;
|
||||
openFileLocation.Code = 65;
|
||||
|
||||
var openConsole = new HotkeySettings();
|
||||
openConsole.Alt = true;
|
||||
openConsole.Code = 68;
|
||||
|
||||
var copyFileLocation = new HotkeySettings();
|
||||
copyFileLocation.Shift = true;
|
||||
copyFileLocation.Code = 70;
|
||||
|
||||
viewModel.OpenPowerLauncher = openPowerLauncher;
|
||||
viewModel.OpenFileLocation = openFileLocation;
|
||||
viewModel.CopyPathLocation = copyFileLocation;
|
||||
|
||||
Assert.AreEqual(3, sendCallbackMock.TimesSent);
|
||||
|
||||
AssertHotkeySettings(
|
||||
mockSettings.Properties.OpenPowerLauncher,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
83);
|
||||
AssertHotkeySettings(
|
||||
mockSettings.Properties.OpenFileLocation,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
65);
|
||||
AssertHotkeySettings(
|
||||
mockSettings.Properties.CopyPathLocation,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
70);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OverrideShouldUpdateOverrides()
|
||||
{
|
||||
viewModel.OverrideWinRKey = true;
|
||||
viewModel.OverrideWinSKey = false;
|
||||
|
||||
Assert.AreEqual(1, sendCallbackMock.TimesSent);
|
||||
|
||||
Assert.IsTrue(mockSettings.Properties.OverrideWinkeyR);
|
||||
Assert.IsFalse(mockSettings.Properties.OverrideWinkeyS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class PowerPreview
|
||||
{
|
||||
private Mock<ISettingsUtils> mockPowerPreviewSettingsUtils;
|
||||
|
||||
private Mock<ISettingsUtils> mockGeneralSettingsUtils;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUpStubSettingUtils()
|
||||
{
|
||||
mockPowerPreviewSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<PowerPreviewSettings>();
|
||||
mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if the original settings files were modified.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DataRow("v0.18.2", "settings.json")]
|
||||
[DataRow("v0.19.2", "settings.json")]
|
||||
[DataRow("v0.20.1", "settings.json")]
|
||||
[DataRow("v0.21.1", "settings.json")]
|
||||
[DataRow("v0.22.0", "settings.json")]
|
||||
public void OriginalFilesModificationTest(string version, string fileName)
|
||||
{
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
var fileMock = BackCompatTestProperties.GetModuleIOProvider(version, PowerPreviewSettings.ModuleName, fileName);
|
||||
|
||||
var mockSettingsUtils = new SettingsUtils(fileMock.Object, settingPathMock.Object);
|
||||
PowerPreviewSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault<PowerPreviewSettings>(PowerPreviewSettings.ModuleName);
|
||||
var repository = new BackCompatTestProperties.MockSettingsRepository<PowerPreviewSettings>(mockSettingsUtils);
|
||||
|
||||
var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
|
||||
// Initialise View Model with test Config files
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(repository, generalSettingsRepository, sendMockIPCConfigMSG);
|
||||
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.IsElevated, viewModel.IsElevated);
|
||||
Assert.AreEqual(originalSettings.Properties.EnableMdPreview, viewModel.MDRenderIsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.EnablePdfPreview, viewModel.PDFRenderIsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.EnableGcodePreview, viewModel.GCODERenderIsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.EnableSvgPreview, viewModel.SVGRenderIsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.EnableSvgThumbnail, viewModel.SVGThumbnailIsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.EnablePdfThumbnail, viewModel.PDFThumbnailIsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.EnableGcodeThumbnail, viewModel.GCODEThumbnailIsEnabled);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyModuleIOProviderWasRead(fileMock, PowerPreviewSettings.ModuleName, expectedCallCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SVGRenderIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableSvgPreview);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||
|
||||
// act
|
||||
viewModel.SVGRenderIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SVGThumbnailIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableSvgThumbnail);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||
|
||||
// act
|
||||
viewModel.SVGThumbnailIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PDFThumbnailIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnablePdfThumbnail);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||
|
||||
// act
|
||||
viewModel.PDFThumbnailIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GCODEThumbnailIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableGcodeThumbnail);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||
|
||||
// act
|
||||
viewModel.GCODEThumbnailIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MDRenderIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableMdPreview);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||
|
||||
// act
|
||||
viewModel.MDRenderIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PDFRenderIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnablePdfPreview);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||
|
||||
// act
|
||||
viewModel.PDFRenderIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GCODERenderIsEnabledShouldPrevHandlerWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableGcodePreview);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel(SettingsRepository<PowerPreviewSettings>.GetInstance(mockPowerPreviewSettingsUtils.Object), SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, PowerPreviewSettings.ModuleName);
|
||||
|
||||
// act
|
||||
viewModel.GCODERenderIsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class PowerRename
|
||||
{
|
||||
public const string GeneralSettingsFileName = "Test\\PowerRename";
|
||||
|
||||
private Mock<ISettingsUtils> mockGeneralSettingsUtils;
|
||||
|
||||
private Mock<ISettingsUtils> mockPowerRenamePropertiesUtils;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUpStubSettingUtils()
|
||||
{
|
||||
mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
mockPowerRenamePropertiesUtils = ISettingsUtilsMocks.GetStubSettingsUtils<PowerRenameLocalProperties>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if the original settings files were modified.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DataRow("v0.18.2", "power-rename-settings.json")]
|
||||
[DataRow("v0.19.2", "power-rename-settings.json")]
|
||||
[DataRow("v0.20.1", "power-rename-settings.json")]
|
||||
[DataRow("v0.22.0", "power-rename-settings.json")]
|
||||
public void OriginalFilesModificationTest(string version, string fileName)
|
||||
{
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
var mockIOProvider = BackCompatTestProperties.GetModuleIOProvider(version, PowerRenameSettings.ModuleName, fileName);
|
||||
|
||||
var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object, settingPathMock.Object);
|
||||
PowerRenameLocalProperties originalSettings = mockSettingsUtils.GetSettingsOrDefault<PowerRenameLocalProperties>(PowerRenameSettings.ModuleName);
|
||||
|
||||
var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
|
||||
// Initialise View Model with test Config files
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockSettingsUtils, generalSettingsRepository, sendMockIPCConfigMSG);
|
||||
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.Enabled.PowerRename, viewModel.IsEnabled);
|
||||
Assert.AreEqual(originalSettings.ExtendedContextMenuOnly, viewModel.EnabledOnContextExtendedMenu);
|
||||
Assert.AreEqual(originalSettings.MRUEnabled, viewModel.MRUEnabled);
|
||||
Assert.AreEqual(originalSettings.ShowIcon, viewModel.EnabledOnContextMenu);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyModuleIOProviderWasRead(mockIOProvider, PowerRenameSettings.ModuleName, expectedCallCount);
|
||||
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsEnabledShouldEnableModuleWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsTrue(snd.GeneralSettings.Enabled.PowerRename);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
// act
|
||||
viewModel.IsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MRUEnabledShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.MRUEnabled.Value);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
// act
|
||||
viewModel.MRUEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOffAndMRUEnabledIsOffGlobalAndMruShouldBeOff()
|
||||
{
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
viewModel.IsEnabled = false;
|
||||
viewModel.MRUEnabled = false;
|
||||
|
||||
Assert.IsFalse(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOffAndMRUEnabledIsOnGlobalAndMruShouldBeOff()
|
||||
{
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
viewModel.IsEnabled = false;
|
||||
viewModel.MRUEnabled = true;
|
||||
|
||||
Assert.IsFalse(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOnAndMRUEnabledIsOffGlobalAndMruShouldBeOff()
|
||||
{
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
viewModel.IsEnabled = true;
|
||||
viewModel.MRUEnabled = false;
|
||||
|
||||
Assert.IsFalse(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenIsEnabledIsOnAndMRUEnabledIsOnGlobalAndMruShouldBeOn()
|
||||
{
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
viewModel.IsEnabled = true;
|
||||
viewModel.MRUEnabled = true;
|
||||
|
||||
Assert.IsTrue(viewModel.GlobalAndMruEnabled);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EnabledOnContextMenuShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.ShowIcon.Value);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
// act
|
||||
viewModel.EnabledOnContextMenu = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EnabledOnContextExtendedMenuShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.ShowIcon.Value);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
// act
|
||||
viewModel.EnabledOnContextMenu = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RestoreFlagsOnLaunchShouldSetValue2TrueWhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.PowerRename.Properties.PersistState.Value);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
// act
|
||||
viewModel.RestoreFlagsOnLaunch = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MaxDispListNumShouldSetMaxSuggListTo20WhenSuccessful()
|
||||
{
|
||||
// Assert
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
PowerRenameSettingsIPCMessage snd = JsonSerializer.Deserialize<PowerRenameSettingsIPCMessage>(msg);
|
||||
Assert.AreEqual(20, snd.Powertoys.PowerRename.Properties.MaxMRUSize.Value);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// arrange
|
||||
PowerRenameViewModel viewModel = new PowerRenameViewModel(mockPowerRenamePropertiesUtils.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, GeneralSettingsFileName);
|
||||
|
||||
// act
|
||||
viewModel.MaxDispListNum = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.BackwardsCompatibility;
|
||||
using Microsoft.PowerToys.Settings.UI.UnitTests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ShortcutGuide
|
||||
{
|
||||
public const string ShortCutGuideTestFolderName = "Test\\ShortCutGuide";
|
||||
|
||||
/// <summary>
|
||||
/// Test if the original settings files were modified.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[DataRow("v0.18.2", "settings.json")]
|
||||
[DataRow("v0.19.2", "settings.json")]
|
||||
[DataRow("v0.20.1", "settings.json")]
|
||||
[DataRow("v0.21.1", "settings.json")]
|
||||
[DataRow("v0.22.0", "settings.json")]
|
||||
public void OriginalFilesModificationTest(string version, string fileName)
|
||||
{
|
||||
var settingPathMock = new Mock<ISettingsPath>();
|
||||
var mockIOProvider = BackCompatTestProperties.GetModuleIOProvider(version, ShortcutGuideSettings.ModuleName, fileName);
|
||||
var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object, settingPathMock.Object);
|
||||
ShortcutGuideSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault<ShortcutGuideSettings>(ShortcutGuideSettings.ModuleName);
|
||||
|
||||
var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
|
||||
var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object);
|
||||
GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault<GeneralSettings>();
|
||||
var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<GeneralSettings>(mockGeneralSettingsUtils);
|
||||
var shortcutSettingsRepository = new BackCompatTestProperties.MockSettingsRepository<ShortcutGuideSettings>(mockSettingsUtils);
|
||||
|
||||
// Initialise View Model with test Config files
|
||||
Func<string, int> sendMockIPCConfigMSG = msg => { return 0; };
|
||||
ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel(mockSettingsUtils, generalSettingsRepository, shortcutSettingsRepository, sendMockIPCConfigMSG);
|
||||
|
||||
// Verify that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.Enabled.ShortcutGuide, viewModel.IsEnabled);
|
||||
Assert.AreEqual(originalSettings.Properties.OverlayOpacity.Value, viewModel.OverlayOpacity);
|
||||
|
||||
// Verify that the stub file was used
|
||||
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)
|
||||
BackCompatTestProperties.VerifyModuleIOProviderWasRead(mockIOProvider, ShortcutGuideSettings.ModuleName, expectedCallCount);
|
||||
BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount);
|
||||
}
|
||||
|
||||
private Mock<ISettingsUtils> mockGeneralSettingsUtils;
|
||||
|
||||
private Mock<ISettingsUtils> mockShortcutGuideSettingsUtils;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUpStubSettingUtils()
|
||||
{
|
||||
mockGeneralSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<GeneralSettings>();
|
||||
mockShortcutGuideSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils<ShortcutGuideSettings>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsEnabledShouldEnableModuleWhenSuccessful()
|
||||
{
|
||||
var settingsUtilsMock = new Mock<SettingsUtils>();
|
||||
|
||||
// Assert
|
||||
// Initialize mock function of sending IPC message.
|
||||
Func<string, int> sendMockIPCConfigMSG = msg =>
|
||||
{
|
||||
OutGoingGeneralSettings snd = JsonSerializer.Deserialize<OutGoingGeneralSettings>(msg);
|
||||
Assert.IsTrue(snd.GeneralSettings.Enabled.ShortcutGuide);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// Arrange
|
||||
ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel(settingsUtilsMock.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<ShortcutGuideSettings>.GetInstance(mockShortcutGuideSettingsUtils.Object), sendMockIPCConfigMSG, ShortCutGuideTestFolderName);
|
||||
|
||||
// Act
|
||||
viewModel.IsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ThemeIndexShouldSetThemeToDarkWhenSuccessful()
|
||||
{
|
||||
// Arrange
|
||||
var settingsUtilsMock = new Mock<ISettingsUtils>();
|
||||
ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel(settingsUtilsMock.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<ShortcutGuideSettings>.GetInstance(mockShortcutGuideSettingsUtils.Object), msg => { return 0; }, ShortCutGuideTestFolderName);
|
||||
|
||||
// Initialize shortcut guide settings theme to 'system' to be in sync with shortcut_guide.h.
|
||||
Assert.AreEqual(2, viewModel.ThemeIndex);
|
||||
|
||||
// Act
|
||||
viewModel.ThemeIndex = 0;
|
||||
|
||||
// Assert
|
||||
Func<string, bool> isDark = s => JsonSerializer.Deserialize<ShortcutGuideSettings>(s).Properties.Theme.Value == "dark";
|
||||
settingsUtilsMock.Verify(x => x.SaveSettings(It.Is<string>(y => isDark(y)), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OverlayOpacityShouldSeOverlayOpacityToOneHundredWhenSuccessful()
|
||||
{
|
||||
// Arrange
|
||||
var settingsUtilsMock = new Mock<ISettingsUtils>();
|
||||
ShortcutGuideViewModel viewModel = new ShortcutGuideViewModel(settingsUtilsMock.Object, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SettingsRepository<ShortcutGuideSettings>.GetInstance(mockShortcutGuideSettingsUtils.Object), msg => { return 0; }, ShortCutGuideTestFolderName);
|
||||
Assert.AreEqual(90, viewModel.OverlayOpacity);
|
||||
|
||||
// Act
|
||||
viewModel.OverlayOpacity = 100;
|
||||
|
||||
// Assert
|
||||
Func<string, bool> equal100 = s => JsonSerializer.Deserialize<ShortcutGuideSettings>(s).Properties.OverlayOpacity.Value == 100;
|
||||
settingsUtilsMock.Verify(x => x.SaveSettings(It.Is<string>(y => equal100(y)), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user