logindtest

package
v0.3.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func (l *Logind) PrepareForSleep(start bool) error

PrepareForSleep emits the manager's PrepareForSleep(start).

func (*Logind) SetLockedHint added in v0.3.15

func (l *Logind) SetLockedHint(locked bool) error

SetLockedHint changes the display session's LockedHint and announces it with PropertiesChanged, as logind does when the lock screen sets it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL