Files
ThreadPilot/Tests/ThreadPilot.Core.Tests/AppRefreshPolicyTests.cs
T
Prime Build 266834cbdf Reduce Performance tab to optional diagnostics (#17)
Reduce Performance tab to optional diagnostics

Hide the Performance/Diagnostics surface from the primary UX by default and remove hidden startup/tray runtime cost.

- Hide Diagnostics from primary navigation and tray by default
- Lazy-create PerformanceViewModel only when Diagnostics is opened
- Stop initializing diagnostics snapshots during app startup
- Gate tray CPU/RAM metrics behind the advanced diagnostics flag
- Avoid starting the tray lightweight metrics timer when diagnostics are hidden
- Lazily allocate PerformanceMonitoringService counters on first metrics use
- Stop live diagnostics when inactive, minimized or tray-hidden
- Preserve diagnostics internals for future selected-process summary work
- Add tests for lazy diagnostics creation, tray metrics gating and explicit diagnostics activation

No Process tab redesign, CPU affinity changes, memory priority changes, persistent rules changes, version bump or tag changes.
2026-05-21 23:47:21 +02:00

64 lines
3.3 KiB
C#

namespace ThreadPilot.Core.Tests
{
using ThreadPilot.Services;
public sealed class AppRefreshPolicyTests
{
[Theory]
[InlineData(AppActivityState.ForegroundProcessView, true, true, true, false, true, true)]
[InlineData(AppActivityState.ForegroundDiagnosticsView, false, false, false, true, true, true)]
[InlineData(AppActivityState.ForegroundOtherTab, false, false, false, false, true, true)]
[InlineData(AppActivityState.Minimized, false, false, false, false, false, true)]
[InlineData(AppActivityState.TrayHidden, false, false, false, false, false, true)]
public void Evaluate_ReturnsExpectedRefreshDecision(
AppActivityState state,
bool processUiRefreshEnabled,
bool immediateProcessRefresh,
bool virtualizedPreloadEnabled,
bool performanceUiMonitoringEnabled,
bool powerPlanUiRefreshEnabled,
bool backgroundAutomationEnabled)
{
var decision = AppRefreshPolicy.Evaluate(state);
Assert.Equal(processUiRefreshEnabled, decision.ProcessUiRefreshEnabled);
Assert.Equal(immediateProcessRefresh, decision.ImmediateProcessRefresh);
Assert.Equal(virtualizedPreloadEnabled, decision.VirtualizedPreloadEnabled);
Assert.Equal(performanceUiMonitoringEnabled, decision.PerformanceUiMonitoringEnabled);
Assert.Equal(powerPlanUiRefreshEnabled, decision.PowerPlanUiRefreshEnabled);
Assert.Equal(backgroundAutomationEnabled, decision.BackgroundAutomationEnabled);
}
[Fact]
public void Evaluate_WhenStateIsUnknown_KeepsBackgroundAutomationOnly()
{
var decision = AppRefreshPolicy.Evaluate((AppActivityState)999);
Assert.False(decision.ProcessUiRefreshEnabled);
Assert.False(decision.ImmediateProcessRefresh);
Assert.False(decision.VirtualizedPreloadEnabled);
Assert.False(decision.PerformanceUiMonitoringEnabled);
Assert.False(decision.PowerPlanUiRefreshEnabled);
Assert.True(decision.BackgroundAutomationEnabled);
}
[Theory]
[InlineData(null, AppActivityState.ForegroundProcessView, true)]
[InlineData(AppActivityState.ForegroundProcessView, AppActivityState.ForegroundProcessView, false)]
[InlineData(AppActivityState.ForegroundDiagnosticsView, AppActivityState.ForegroundDiagnosticsView, false)]
[InlineData(AppActivityState.ForegroundOtherTab, AppActivityState.ForegroundOtherTab, false)]
[InlineData(AppActivityState.Minimized, AppActivityState.Minimized, false)]
[InlineData(AppActivityState.TrayHidden, AppActivityState.TrayHidden, false)]
[InlineData(AppActivityState.TrayHidden, AppActivityState.ForegroundProcessView, true)]
[InlineData(AppActivityState.ForegroundProcessView, AppActivityState.ForegroundOtherTab, true)]
[InlineData(AppActivityState.ForegroundOtherTab, AppActivityState.ForegroundDiagnosticsView, true)]
public void ShouldApplyTransition_SkipsRedundantStateTransitions(
AppActivityState? previousState,
AppActivityState nextState,
bool expected)
{
Assert.Equal(expected, AppRefreshPolicy.ShouldApplyTransition(previousState, nextState));
}
}
}