mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-30 17:42:06 -04:00
loginctl: simplify event handling
This commit is contained in:
@@ -35,12 +35,7 @@ type SessionState struct {
|
||||
type EventType string
|
||||
|
||||
const (
|
||||
EventStateChanged EventType = "state_changed"
|
||||
EventLock EventType = "lock"
|
||||
EventUnlock EventType = "unlock"
|
||||
EventPrepareForSleep EventType = "prepare_for_sleep"
|
||||
EventIdleHintChanged EventType = "idle_hint_changed"
|
||||
EventLockedHintChanged EventType = "locked_hint_changed"
|
||||
EventStateChanged EventType = "state_changed"
|
||||
)
|
||||
|
||||
type SessionEvent struct {
|
||||
|
||||
@@ -8,11 +8,6 @@ import (
|
||||
|
||||
func TestEventType_Constants(t *testing.T) {
|
||||
assert.Equal(t, EventType("state_changed"), EventStateChanged)
|
||||
assert.Equal(t, EventType("lock"), EventLock)
|
||||
assert.Equal(t, EventType("unlock"), EventUnlock)
|
||||
assert.Equal(t, EventType("prepare_for_sleep"), EventPrepareForSleep)
|
||||
assert.Equal(t, EventType("idle_hint_changed"), EventIdleHintChanged)
|
||||
assert.Equal(t, EventType("locked_hint_changed"), EventLockedHintChanged)
|
||||
}
|
||||
|
||||
func TestSessionState_Struct(t *testing.T) {
|
||||
@@ -40,11 +35,11 @@ func TestSessionEvent_Struct(t *testing.T) {
|
||||
}
|
||||
|
||||
event := SessionEvent{
|
||||
Type: EventLock,
|
||||
Type: EventStateChanged,
|
||||
Data: state,
|
||||
}
|
||||
|
||||
assert.Equal(t, EventLock, event.Type)
|
||||
assert.Equal(t, EventStateChanged, event.Type)
|
||||
assert.Equal(t, "1", event.Data.SessionID)
|
||||
assert.True(t, event.Data.Locked)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user