From 8a2fdca92d7fcf8bc2b202d80f761de86d413187 Mon Sep 17 00:00:00 2001 From: seraphima Date: Thu, 29 Feb 2024 17:27:22 +0100 Subject: [PATCH] prepare editor files before launch --- .../RunFancyZonesEditorTest.cs | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs b/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs index 0941ff3297..95f254f21f 100644 --- a/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs +++ b/src/modules/fancyzones/UITests-FancyZonesEditor/RunFancyZonesEditorTest.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using FancyZonesEditorCommon.Data; +using Microsoft.FancyZonesEditor.UITests; using Microsoft.FancyZonesEditor.UnitTests.Utils; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -18,11 +20,118 @@ namespace UITests_FancyZonesEditor public static void ClassInitialize(TestContext testContext) { _context = testContext; + + // prepare files to launch Editor without errors + EditorParameters editorParameters = new EditorParameters(); + EditorParameters.ParamsWrapper parameters = new EditorParameters.ParamsWrapper + { + ProcessId = 1, + SpanZonesAcrossMonitors = false, + Monitors = new List + { + new EditorParameters.NativeMonitorDataWrapper + { + Monitor = "monitor-1", + MonitorInstanceId = "instance-id-1", + MonitorSerialNumber = "serial-number-1", + MonitorNumber = 1, + VirtualDesktop = "{FF34D993-73F3-4B8C-AA03-73730A01D6A8}", + Dpi = 96, + LeftCoordinate = 0, + TopCoordinate = 0, + WorkAreaHeight = 1040, + WorkAreaWidth = 1920, + MonitorHeight = 1080, + MonitorWidth = 1920, + IsSelected = true, + }, + }, + }; + FancyZonesEditorSession.Files.ParamsIOHelper.WriteData(editorParameters.Serialize(parameters)); + + LayoutTemplates layoutTemplates = new LayoutTemplates(); + LayoutTemplates.TemplateLayoutsListWrapper templateLayoutsListWrapper = new LayoutTemplates.TemplateLayoutsListWrapper + { + LayoutTemplates = new List + { + new LayoutTemplates.TemplateLayoutWrapper + { + Type = Constants.LayoutTypes[Constants.Layouts.Empty], + }, + new LayoutTemplates.TemplateLayoutWrapper + { + Type = Constants.LayoutTypes[Constants.Layouts.Focus], + ZoneCount = 10, + }, + new LayoutTemplates.TemplateLayoutWrapper + { + Type = Constants.LayoutTypes[Constants.Layouts.Rows], + ZoneCount = 2, + ShowSpacing = true, + Spacing = 10, + SensitivityRadius = 10, + }, + new LayoutTemplates.TemplateLayoutWrapper + { + Type = Constants.LayoutTypes[Constants.Layouts.Columns], + ZoneCount = 2, + ShowSpacing = true, + Spacing = 20, + SensitivityRadius = 20, + }, + new LayoutTemplates.TemplateLayoutWrapper + { + Type = Constants.LayoutTypes[Constants.Layouts.Grid], + ZoneCount = 4, + ShowSpacing = false, + Spacing = 10, + SensitivityRadius = 30, + }, + new LayoutTemplates.TemplateLayoutWrapper + { + Type = Constants.LayoutTypes[Constants.Layouts.PriorityGrid], + ZoneCount = 3, + ShowSpacing = true, + Spacing = 1, + SensitivityRadius = 40, + }, + }, + }; + FancyZonesEditorSession.Files.LayoutTemplatesIOHelper.WriteData(layoutTemplates.Serialize(templateLayoutsListWrapper)); + + CustomLayouts customLayouts = new CustomLayouts(); + CustomLayouts.CustomLayoutListWrapper customLayoutListWrapper = new CustomLayouts.CustomLayoutListWrapper + { + CustomLayouts = new List { }, + }; + FancyZonesEditorSession.Files.CustomLayoutsIOHelper.WriteData(customLayouts.Serialize(customLayoutListWrapper)); + + DefaultLayouts defaultLayouts = new DefaultLayouts(); + DefaultLayouts.DefaultLayoutsListWrapper defaultLayoutsListWrapper = new DefaultLayouts.DefaultLayoutsListWrapper + { + DefaultLayouts = new List { }, + }; + FancyZonesEditorSession.Files.DefaultLayoutsIOHelper.WriteData(defaultLayouts.Serialize(defaultLayoutsListWrapper)); + + LayoutHotkeys layoutHotkeys = new LayoutHotkeys(); + LayoutHotkeys.LayoutHotkeysWrapper layoutHotkeysWrapper = new LayoutHotkeys.LayoutHotkeysWrapper + { + LayoutHotkeys = new List { }, + }; + FancyZonesEditorSession.Files.LayoutHotkeysIOHelper.WriteData(layoutHotkeys.Serialize(layoutHotkeysWrapper)); + + AppliedLayouts appliedLayouts = new AppliedLayouts(); + AppliedLayouts.AppliedLayoutsListWrapper appliedLayoutsWrapper = new AppliedLayouts.AppliedLayoutsListWrapper + { + AppliedLayouts = new List { }, + }; + FancyZonesEditorSession.Files.AppliedLayoutsIOHelper.WriteData(appliedLayouts.Serialize(appliedLayoutsWrapper)); } [ClassCleanup] public static void ClassCleanup() { + FancyZonesEditorSession.Files.Restore(); _context = null; }