9a4baba19a
* feat: back up persistent rules and resolve rule precedence deterministically
- Configuration export now includes persistent process rules (schema 3.0),
stays compatible with 2.0 bundles, validates before writing, previews
what an import replaces and rolls back on failure.
- Matching rules apply broad-to-specific (name, wildcard path, exact path,
then most recently edited), shared by the engine and the process summary,
which now lists the apply order and flags conflicting values.
- Localized the new strings in all seven languages.
* feat: clearer process and rule editors
- Process details: CPU, memory and I/O priority pickers with an explicit
Apply, undo of the last manual priority change (guarded against reused
PIDs), adaptive side/bottom details panel.
- Manual process control stays available while automation is paused, with
a persistent notice instead of an overlay.
- Saved-rule editor stages all edits (including the core mask) and saves
them together, showing pending changes.
- Localized the new strings in all seven languages.
* fix: one save path for a saved rule's cores
The rules editor's core mask went through a new update path that reported
success without saving when no affinity payload was built, and kept a
legacy mask next to a CPU selection. Merge it with the old single-purpose
method (now unused), keep its checks, and localize the undo message.
* feat: per-process efficiency mode (EcoQoS) for live processes and rules
Closes #66.
- Native: SetProcessInformation/GetProcessInformation with
ProcessPowerThrottling (EXECUTION_SPEED), three states: Windows decides,
On (EcoQoS), Off (never throttle / HighQoS).
- Process tab: context menu entries, a picker with Apply in the details
panel, current state in the summary, undo of the last change, included
when saving current settings as a rule (only if explicitly set).
- Rules: EfficiencyMode + ApplyEfficiencyModeOnStart, applied by the rules
engine, editable in the saved-rule editor, validated on import and part
of conflict detection.
- The summary flags when the global Power Throttling tweak voids it. CPU
priority is left alone, unlike Task Manager's efficiency mode.
- Localized in all seven languages.
* chore: keep CRLF line endings in SelectedProcessSummaryViewModel
* feat: clearer navigation, process page and rules editor
- Navigation pane open with short labels instead of seven bare icons.
- Processes: one toolbar row (search with placeholder, Filters and
Columns menus, sort, refresh); details split into Process, Priority,
CPU cores and Rule cards; pickers start from the process's current
values and stay empty when a value cannot be read; help paragraphs
moved into tooltips; core picker always visible.
- Rules: process rules first, clearer tab names, localized choices in the
saved-rule editor instead of internal enum names.
- Shorter page titles and subtitles in all seven languages; removed the
strings this made unused.
No data format changes.
* feat: settings and tweaks as Windows 11 rows, localized rule list
- Settings: one column of rows (what it is on the left, its switch on the
right), most used sections first, Save as the primary action.
- Tweaks: one tweak per row with its status dot and switch.
- Rule list: 'Applies' and 'Mode' columns use the same localized labels as
the editor and refresh on language change.
- Removed 76 strings no code referenced, from all seven languages.
* fix: issues found testing the beta in a clean Windows 11 VM
- Process counter could show more visible processes than the total
('157 / 151'): the batch total was a snapshot from the first load.
- Narrow windows (or 150% scaling): toolbar buttons move under the search
box instead of squeezing it to a few letters.
- Rules list keeps the 'Applies' column readable when narrow.
- Settings status message gets its own line instead of being cut.
Tested in a Hyper-V Windows 11 VM: clean install, upgrade, uninstall,
light and dark theme, 100% and 150% scaling.
* feat: remember layout choices; Windows 11 toggles in Tweaks
- The navigation pane, window size/position/maximized state, and the
process list filters, sort and columns now survive a restart. They live
in ui-state.json, apart from settings.json, so they never mark the
Settings page as unsaved or travel in exported configurations. A corrupt
file falls back to defaults; tests write to a temp file.
- Fixes the pane re-opening on every start (it was hard-coded open).
- Tweaks use a native-looking Windows 11 switch (40x20 track, sliding
thumb) with On/Off written beside it.
- New test: every on/off setting survives save and reload.
* docs: handoff for the 1.7.7 PR stack and beta test
* fix: P/E cores from the highest EfficiencyClass, AMD CCDs from real L3 groups
The legacy topology treated the lowest EfficiencyClass as the performance
core, swapping P- and E-cores on hybrid Intel CPUs. AMD CCDs were guessed
as 8 cores each, which split 6+6 parts (7900X3D, 9900X3D) into 8+4; they now
come from the L3 groups Windows reports, with the guess kept only as a
fallback. The topology snapshot also keeps each L3 group's size.
* feat: Game Boost, CPU Sets for the game and selected background apps
While a detected game runs, Game Boost sets process default CPU Sets from
the CPU topology: on AMD X3D with one larger L3 the game goes to the V-Cache
CCD, on Intel hybrid CPUs to the P-cores, and selected background apps
(browsers, sync clients, updaters, launchers) to the other cores. On dual-CCD
parts with equal L3 only the background moves, unless Isolation mode also
keeps the game on CCD0. Single-L3 and unreadable topologies are left to
Windows. Above Normal priority for the game is optional; never High.
Each change is written to a journal before it is made and undone when the
game exits, Game Boost is turned off or ThreadPilot closes, and on the next
start after a crash. Only values still exactly as Game Boost set them are
restored, never one a user rule or a manual change has taken over since.
Persistent rules and Game Boost share one apply gate, and a rule always
wins over Game Boost for the setting it covers.
The switch, mode and lists are on the Tweaks page, off by default, and take
effect without a restart.
* fix: Game Boost background entries with a full path never matched
The background list compared full-path entries against an empty path, so
only bare process names worked. Found by a new integration test that runs
the real services on two copies of PING.EXE: CPU Sets and priority are set
and read back through Windows, removed when Game Boost is turned off, and
undone from the journal after a simulated crash. The topology is simulated
from this machine's CPU Set IDs, so the test also runs on CPUs where Game
Boost would not act; it skips itself below 8 cores.
* feat: report Game Boost sessions and restore results in Activity
* test: diagnose EcoQoS read failures on Windows Server
* chore: prepare 1.7.7-beta.2 and keep prereleases out of stable channels
* test: use native full-query access mask in EcoQoS diagnostic
* docs: update beta handoff and prerelease publication policy
* ci: run native EcoQoS tests on a Windows 11-era kernel
Windows Server 2022 build 20348 rejects GetProcessInformation(ProcessPowerThrottling) with ERROR_INVALID_PARAMETER (87), with both limited and full query handles. Windows 11 local tests pass. Use Server 2025 for CI/release tests and smoke testing; keep the real round-trip assertions, remove temporary probes.
* test: lock beta publication and native runner contracts
* chore: separate stable 1.7.7 from experimental Game Boost
Stable retains the validated EcoQoS/rules/UI stack. Preserve the complete local Game Boost implementation at ef2ec24 for the separate 1.7.8-beta.1 prerelease; no experimental Game Boost/topology changes ship in stable. Keep channel-aware publication and Windows 11-era native CI tests.
348 lines
21 KiB
C#
348 lines
21 KiB
C#
namespace ThreadPilot.Core.Tests
|
|
{
|
|
using System.Xml.Linq;
|
|
|
|
public sealed class ProcessViewXamlBindingTests
|
|
{
|
|
private static readonly string ProcessViewPath = Path.Combine(
|
|
AppContext.BaseDirectory,
|
|
"..",
|
|
"..",
|
|
"..",
|
|
"..",
|
|
"..",
|
|
"Views",
|
|
"ProcessView.xaml");
|
|
|
|
[Fact]
|
|
public void LastOperationMessageBinding_IsDisplayOnly()
|
|
{
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var lastOperationBindings = document
|
|
.Descendants()
|
|
.SelectMany(element => element.Attributes().Select(attribute => new
|
|
{
|
|
Element = element.Name.LocalName,
|
|
Attribute = attribute.Name.LocalName,
|
|
Value = attribute.Value,
|
|
}))
|
|
.Where(attribute => attribute.Value.Contains("SelectedProcessSummary.LastOperationMessage", StringComparison.Ordinal))
|
|
.ToList();
|
|
|
|
var binding = Assert.Single(lastOperationBindings);
|
|
Assert.Equal("Text", binding.Attribute);
|
|
Assert.Contains("Mode=OneWay", binding.Value, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void SelectedProcessSummaryBindings_AreNotUsedByEditableControls()
|
|
{
|
|
var editableControls = new HashSet<string>(StringComparer.Ordinal)
|
|
{
|
|
"CheckBox",
|
|
"ComboBox",
|
|
"DatePicker",
|
|
"PasswordBox",
|
|
"Slider",
|
|
"TextBox",
|
|
"ToggleButton",
|
|
};
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
|
|
var editableSummaryBindings = document
|
|
.Descendants()
|
|
.Where(element => editableControls.Contains(element.Name.LocalName))
|
|
.SelectMany(element => element.Attributes().Select(attribute => new
|
|
{
|
|
Element = element.Name.LocalName,
|
|
Attribute = attribute.Name.LocalName,
|
|
Value = attribute.Value,
|
|
}))
|
|
.Where(attribute => attribute.Value.Contains("SelectedProcessSummary.", StringComparison.Ordinal))
|
|
.ToList();
|
|
|
|
Assert.Empty(editableSummaryBindings);
|
|
}
|
|
|
|
[Fact]
|
|
public void CpuAssignmentMode_IsStagedTwoWayAndHasAccessibleHelp()
|
|
{
|
|
var serialized = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace)
|
|
.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("SelectedValue=\"{Binding SelectedCpuAssignmentMode, Mode=TwoWay}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("CpuAssignmentMode.AffinityMask", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("CpuAssignmentMode.IdealProcessor", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("CpuAssignmentMode.CpuSets", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("CpuAssignmentMode.Automatic", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("AutomationProperties.HelpText=\"{DynamicResource ProcessView_CpuAssignmentModeTooltip}\"", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessGridRowStyle_HighlightsSelectedRowsWithNeutralTheme()
|
|
{
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("IsSelected", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("SoftSelectionBackgroundBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("SoftSelectionBorderBrush", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("Property=\"BorderBrush\" Value=\"{DynamicResource AccentBrush}\"", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessGridContextMenu_MenuItemsUseStableDetachedMenuStyle()
|
|
{
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("<ContextMenu", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Style=\"{StaticResource ProcessContextMenuStyle}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("TargetType=\"{x:Type MenuItem}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("FontWeight\" Value=\"Normal\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("FontSize\" Value=\"{DynamicResource BodyFontSize}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Style=\"{StaticResource ProcessContextMenuItemStyle}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("ControlTemplate TargetType=\"{x:Type MenuItem}\"", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("FontWeight\" Value=\"{Binding", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("FontWeight\" Value=\"{TemplateBinding", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessGridContextMenu_DoesNotApplyMenuItemStyleToSeparators()
|
|
{
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("<Separator", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("ItemContainerStyle", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("<Separator Style=\"{StaticResource ProcessContextMenuItemStyle}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("<Separator Style=\"{StaticResource ProcessContextMenuSeparatorStyle}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("TargetType=\"{x:Type Separator}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("ControlTemplate TargetType=\"{x:Type Separator}\"", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessGridContextMenu_UsesThemeAwareTemplateWithoutIconCheckGutter()
|
|
{
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("TargetType=\"{x:Type ContextMenu}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("TargetType=\"{x:Type MenuItem}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("ControlTemplate TargetType=\"{x:Type MenuItem}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("x:Name=\"SubmenuArrow\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("PART_Popup", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("QuietRowHoverBackgroundBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("CardSurfaceBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("BorderSubtleBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("TextPrimaryBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("TextDisabledBrush", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("Grid.IsSharedSizeScope", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("IconPresenter", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("GlyphPanel", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("Checkmark", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("CheckMark", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("IconHost", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("CheckGlyph", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("SystemColors.Menu", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessGridContextMenu_ThemeResourceKeysExistInLightAndDarkThemes()
|
|
{
|
|
var themePaths = new[]
|
|
{
|
|
Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..", "Themes", "FluentLight.xaml"),
|
|
Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..", "Themes", "FluentDark.xaml"),
|
|
};
|
|
|
|
foreach (var themePath in themePaths)
|
|
{
|
|
var theme = File.ReadAllText(themePath);
|
|
|
|
Assert.Contains("x:Key=\"BodyFontSize\"", theme, StringComparison.Ordinal);
|
|
Assert.Contains("x:Key=\"CardSurfaceBrush\"", theme, StringComparison.Ordinal);
|
|
Assert.Contains("x:Key=\"BorderSubtleBrush\"", theme, StringComparison.Ordinal);
|
|
Assert.Contains("x:Key=\"TextPrimaryBrush\"", theme, StringComparison.Ordinal);
|
|
Assert.Contains("x:Key=\"TextSecondaryBrush\"", theme, StringComparison.Ordinal);
|
|
Assert.Contains("x:Key=\"TextDisabledBrush\"", theme, StringComparison.Ordinal);
|
|
Assert.Contains("x:Key=\"QuietRowHoverBackgroundBrush\"", theme, StringComparison.Ordinal);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessGridContextMenu_ContainsExpectedActionsAndSubmenus()
|
|
{
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_ApplyAffinity}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_ClearCpuSets}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_Rules}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_SaveCurrentRule}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_ApplyAffinitySaveRule}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_SetCpuPriority}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_PriorityBelowNormal}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_PriorityNormal}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_PriorityAboveNormal}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_PriorityHigh}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_RealtimeBlocked}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_SetMemoryPriority}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_PriorityVeryLow}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_PriorityLow}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_PriorityMedium}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_OpenLocation}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_CopyProcessInfo}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Header=\"{DynamicResource ProcessView_RefreshInfo}\"", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessToolbar_ExposesLockProcessListToggle()
|
|
{
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("ProcessView_LockList", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("IsChecked=\"{Binding IsProcessListLocked}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("ProcessView_LockListTooltip", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void PausedAutomation_ShowsNoticeWithoutBlockingManualControls()
|
|
{
|
|
// Pausing automation stops saved rules only; manual process control must stay usable.
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.DoesNotContain("MonitoringDisabledOverlay", serialized, StringComparison.Ordinal);
|
|
var notice = Assert.Single(
|
|
document.Descendants(),
|
|
element => element.Attributes().Any(attribute => attribute.Value == "{DynamicResource ProcessView_AutomationPaused}"));
|
|
var visibility = notice.Attribute("Visibility")?.Value ?? string.Empty;
|
|
Assert.Contains("IsAutomationMonitoringEnabled", visibility, StringComparison.Ordinal);
|
|
Assert.Contains("InverseBoolToVisibilityConverter", visibility, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void MasksView_SelectedCpuTilesUseSubtleMaskSelectionResources()
|
|
{
|
|
var masksViewPath = Path.Combine(
|
|
GetRepositoryRoot(),
|
|
"Views",
|
|
"MasksView.xaml");
|
|
var document = XDocument.Load(masksViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("MaskSelectedBackgroundBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("MaskSelectedBorderBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("BorderThickness\" Value=\"1\"", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("SoftSelectionBackgroundBrush", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void MasksView_SelectedMaskListItemUsesReadableFluentSelection()
|
|
{
|
|
var masksViewPath = Path.Combine(
|
|
GetRepositoryRoot(),
|
|
"Views",
|
|
"MasksView.xaml");
|
|
var document = XDocument.Load(masksViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("x:Key=\"MaskListItemStyle\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("TargetType=\"{x:Type ListBoxItem}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("ItemContainerStyle=\"{StaticResource MaskListItemStyle}\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("MaskSelectedListBackgroundBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("MaskSelectedBorderBrush", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("BorderThickness\" Value=\"1\"", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("Foreground\" Value=\"{DynamicResource TextFillColorPrimaryBrush}\"", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("TextOnAccentFillColorPrimaryBrush", serialized, StringComparison.Ordinal);
|
|
Assert.DoesNotContain("AccentFillColorDefaultBrush", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void MainWindow_ContainsStartupMinimizedSuggestionOverlay()
|
|
{
|
|
var mainWindowPath = Path.Combine(GetRepositoryRoot(), "MainWindow.xaml");
|
|
var document = XDocument.Load(mainWindowPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.Contains("StartupMinimizedSuggestionOverlay", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("MainWindow_StartupMinimizedSuggestionTitle", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("MainWindow_OpenSettings", serialized, StringComparison.Ordinal);
|
|
Assert.Contains("MainWindow_DontShowAgain", serialized, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void MainWindow_QueuesStartupUpdateCheckOnceWithoutBlockingStartup()
|
|
{
|
|
var mainWindowBehaviorPath = Path.Combine(GetRepositoryRoot(), "MainWindow.Behaviors.partial.cs");
|
|
var source = File.ReadAllText(mainWindowBehaviorPath);
|
|
var updateCheckSection = source[
|
|
source.IndexOf("private void QueueStartupUpdateCheck()", StringComparison.Ordinal)..source.IndexOf("private void UpdateLoadingStatus", StringComparison.Ordinal)];
|
|
|
|
Assert.Contains("QueueStartupUpdateCheck();", source, StringComparison.Ordinal);
|
|
Assert.Contains("Interlocked.Exchange(ref this.startupUpdateCheckStarted, 1)", updateCheckSection, StringComparison.Ordinal);
|
|
Assert.Contains("TaskSafety.FireAndForget(this.CheckForUpdatesAtStartupAsync()", updateCheckSection, StringComparison.Ordinal);
|
|
Assert.Contains("GetRequiredService<IUpdateService>()", updateCheckSection, StringComparison.Ordinal);
|
|
Assert.Contains("CheckForUpdatesAsync(new UpdateCheckRequest(UpdateCheckTrigger.Startup))", updateCheckSection, StringComparison.Ordinal);
|
|
Assert.Contains("MessageBox.Show", updateCheckSection, StringComparison.Ordinal);
|
|
Assert.Contains("MessageBoxButton.YesNo", updateCheckSection, StringComparison.Ordinal);
|
|
Assert.Contains("DownloadAndInstallAsync(result.Release)", updateCheckSection, StringComparison.Ordinal);
|
|
Assert.Contains("Startup update check ignored failure", updateCheckSection, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void LegacyActionSidePanel_IsGoneAndItsControlsLiveInTheVisiblePicker()
|
|
{
|
|
// The legacy side panel was Visibility="Collapsed" from v1.2.0 onwards, so the CPU
|
|
// assignment mode picker and Apply button that v1.6.0 added to it were never on screen.
|
|
// They now live in the Advanced Affinity Picker; nothing may be parked in a hidden pane.
|
|
var document = XDocument.Load(ProcessViewPath, LoadOptions.PreserveWhitespace);
|
|
var serialized = document.ToString(SaveOptions.DisableFormatting);
|
|
|
|
// The core picker holds the primary apply action, so it is a plain card, never collapsed.
|
|
var picker = Assert.Single(
|
|
document.Descendants(),
|
|
element => element.Attributes().Any(attribute =>
|
|
attribute.Name.LocalName == "Name" && attribute.Value == "CpuCoresCard"));
|
|
var pickerXml = picker.ToString(SaveOptions.DisableFormatting);
|
|
|
|
Assert.DoesNotContain(picker.AncestorsAndSelf(), element => element.Name.LocalName == "Expander");
|
|
Assert.Contains("SelectedCpuAssignmentMode", pickerXml, StringComparison.Ordinal);
|
|
Assert.Contains("SetAffinityCommand", pickerXml, StringComparison.Ordinal);
|
|
Assert.Contains("ProcessView_CpuCoresReadOnlyHint", pickerXml, StringComparison.Ordinal);
|
|
|
|
// No control a user clicks may be parked in a statically collapsed container again.
|
|
// ControlTemplate parts are exempt: a template child collapsed by default and revealed
|
|
// by a trigger is normal WPF, and its Visibility says nothing about what is on screen.
|
|
var hiddenCommands = document
|
|
.Descendants()
|
|
.Where(element => element.Attribute("Command") != null)
|
|
.Where(element => !element.Ancestors().Any(ancestor => ancestor.Name.LocalName == "ControlTemplate"))
|
|
.Where(element => element.AncestorsAndSelf().Any(ancestor =>
|
|
ancestor.Attribute("Visibility")?.Value == "Collapsed"))
|
|
.Select(element => element.Attribute("Command")!.Value)
|
|
.ToList();
|
|
|
|
Assert.Empty(hiddenCommands);
|
|
}
|
|
|
|
private static string GetRepositoryRoot()
|
|
{
|
|
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (directory != null && !File.Exists(Path.Combine(directory.FullName, "ThreadPilot.csproj")))
|
|
{
|
|
directory = directory.Parent;
|
|
}
|
|
|
|
if (directory == null)
|
|
{
|
|
throw new InvalidOperationException("Repository root was not found.");
|
|
}
|
|
|
|
return directory.FullName;
|
|
}
|
|
}
|
|
}
|