feat: add tray control, priority restoration and session logging
This commit is contained in:
1 parent
4f8f6218ad
commit
4880aa46dc
25 files changed
+3072
-676
No files matched your search
@@ -0,0 +1,52 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestOrdinaryPolicyUsesFreshPriorityAndReleasesHandles(t *testing.T) {
|
||||
t.Run("do not raise a light process after an external demotion", func(t *testing.T) {
|
||||
f := newFake()
|
||||
p := f.add(10, 50, PriorityClassHigh)
|
||||
c := testController(f)
|
||||
defer c.Shutdown()
|
||||
f.onRead = func(v *fakeProcess) { v.info.Prio = PriorityClassBelowNormal; f.onRead = nil }
|
||||
c.Step()
|
||||
assertPriority(t, p, PriorityClassBelowNormal)
|
||||
if p.writes != 0 {
|
||||
t.Fatal("stale priority decision performed a write")
|
||||
}
|
||||
})
|
||||
t.Run("release obsolete denied-write state", func(t *testing.T) {
|
||||
f := newFake()
|
||||
p := f.add(10, 150, PriorityClassNormal)
|
||||
p.writable = false
|
||||
c := testController(f)
|
||||
defer c.Shutdown()
|
||||
c.Step()
|
||||
p.info.RSS = 50
|
||||
c.Step()
|
||||
assertClosed(t, f)
|
||||
})
|
||||
}
|
||||
func TestDeniedHeavyTriggerIsStillLoggedBeforeBackground(t *testing.T) {
|
||||
f := newFake()
|
||||
g := f.add(10, 250, PriorityClassNormal)
|
||||
g.info.Name = "BlockedGame.exe"
|
||||
g.writable = false
|
||||
b := f.add(20, 50, PriorityClassNormal)
|
||||
b.info.Name = "Background.exe"
|
||||
c := testController(f)
|
||||
defer c.Shutdown()
|
||||
text := formatReport(c.Step(), time.Unix(0, 0))
|
||||
if strings.Index(text, "BlockedGame.exe") < 0 || strings.Index(text, "BlockedGame.exe") > strings.Index(text, "Background.exe") {
|
||||
t.Fatal("the triggering process is hidden below background changes", text)
|
||||
}
|
||||
if strings.Contains(text, "NORMAL -> HIGH") {
|
||||
t.Fatal("denied raise was logged as a success")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user