Documentation
¶
Overview ¶
Package logindtest is a fake systemd-logind on a private bus, seen from a caller outside any login session: a shell the systemd user manager started.
Index ¶
Constants ¶
const ( EventLock = "lock" EventLockedHint = "locked-hint" EventUnlockedHint = "unlocked-hint" EventInhibit = "inhibit" EventInhibitorReleased = "inhibitor-released" EventSuspend = "suspend" )
The entries Events records, in the order they happen.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logind ¶
type Logind struct {
// Bus is the private bus logind owns its name on.
Bus *dbustest.Bus
// Terminated lists the session paths Terminate was called on.
Terminated dbustest.Var[[]dbus.ObjectPath]
// Locked lists the session paths Lock was called on, aliases
// resolved.
Locked dbustest.Var[[]dbus.ObjectPath]
// LockedHint is what the sessions report for LockedHint.
LockedHint dbustest.Var[bool]
// Asked counts the GetSession calls, so a test can tell nobody came.
Asked dbustest.Var[int]
// Events lists the lock, LockedHint, inhibitor and suspend events in
// the order they happened.
Events dbustest.Var[[]string]
// Inhibitors counts the sleep delay inhibitors held now.
Inhibitors dbustest.Var[int]
// OnLock runs after a Lock is recorded, as the lock screen answering
// logind's Lock signal would; nil does nothing.
OnLock dbustest.Var[func()]
// contains filtered or unexported fields
}
Logind is the fake. Its manager resolves "auto" to the user's display session, and "self" to nothing, since the caller is in no session. Likewise the /session/auto object alias is the display session, and /session/self does not exist.
func Start ¶
func Start(t *testing.T, display dbus.ObjectPath) *Logind
Start runs the fake on a private bus. display is the user's display session; "" is a user without one.
func StartUnit ¶
func StartUnit(t *testing.T, display dbus.ObjectPath) *Logind
StartUnit runs the fake as the system bus of a process the systemd user manager started: XDG_SESSION_ID unset for the test, and every D-Bus client the test runs dialling the fake for the system bus.
func (*Logind) PrepareForSleep ¶ added in v0.3.15
PrepareForSleep emits the manager's PrepareForSleep(start).
func (*Logind) SetLockedHint ¶ added in v0.3.15
SetLockedHint changes the display session's LockedHint and announces it with PropertiesChanged, as logind does when the lock screen sets it.