2026-04-02 20:51:26 +00:00
|
|
|
// pkg/systray/mock_platform.go
|
2026-03-13 13:32:16 +00:00
|
|
|
package systray
|
|
|
|
|
|
|
|
|
|
// MockPlatform is an exported mock for cross-package integration tests.
|
2026-04-02 20:36:02 +00:00
|
|
|
// Use: platform := systray.NewMockPlatform()
|
2026-03-13 13:32:16 +00:00
|
|
|
type MockPlatform struct{}
|
|
|
|
|
|
2026-04-02 20:36:02 +00:00
|
|
|
// NewMockPlatform creates a tray platform mock.
|
|
|
|
|
// Use: platform := systray.NewMockPlatform()
|
2026-03-13 13:32:16 +00:00
|
|
|
func NewMockPlatform() *MockPlatform { return &MockPlatform{} }
|
|
|
|
|
|
2026-04-02 20:36:02 +00:00
|
|
|
// NewTray creates a mock tray handle for tests.
|
|
|
|
|
// Use: tray := platform.NewTray()
|
2026-03-13 13:32:16 +00:00
|
|
|
func (m *MockPlatform) NewTray() PlatformTray { return &exportedMockTray{} }
|
2026-04-02 20:36:02 +00:00
|
|
|
|
|
|
|
|
// NewMenu creates a mock tray menu for tests.
|
|
|
|
|
// Use: menu := platform.NewMenu()
|
2026-03-13 13:32:16 +00:00
|
|
|
func (m *MockPlatform) NewMenu() PlatformMenu { return &exportedMockMenu{} }
|
|
|
|
|
|
|
|
|
|
type exportedMockTray struct {
|
|
|
|
|
icon, templateIcon []byte
|
|
|
|
|
tooltip, label string
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 13:29:46 +00:00
|
|
|
func (t *exportedMockTray) SetIcon(data []byte) { t.icon = data }
|
|
|
|
|
func (t *exportedMockTray) SetTemplateIcon(data []byte) { t.templateIcon = data }
|
|
|
|
|
func (t *exportedMockTray) SetTooltip(text string) { t.tooltip = text }
|
|
|
|
|
func (t *exportedMockTray) SetLabel(text string) { t.label = text }
|
|
|
|
|
func (t *exportedMockTray) SetMenu(menu PlatformMenu) {}
|
|
|
|
|
func (t *exportedMockTray) AttachWindow(w WindowHandle) {}
|
2026-03-13 13:32:16 +00:00
|
|
|
|
2026-04-02 13:39:36 +00:00
|
|
|
type exportedMockMenu struct {
|
|
|
|
|
items []exportedMockMenuItem
|
|
|
|
|
submenus []*exportedMockMenu
|
|
|
|
|
}
|
2026-03-13 13:32:16 +00:00
|
|
|
|
|
|
|
|
func (m *exportedMockMenu) Add(label string) PlatformMenuItem {
|
|
|
|
|
mi := &exportedMockMenuItem{label: label}
|
|
|
|
|
m.items = append(m.items, *mi)
|
|
|
|
|
return mi
|
|
|
|
|
}
|
|
|
|
|
func (m *exportedMockMenu) AddSeparator() {}
|
2026-04-02 13:39:36 +00:00
|
|
|
func (m *exportedMockMenu) AddSubmenu(label string) PlatformMenu {
|
|
|
|
|
sub := &exportedMockMenu{}
|
|
|
|
|
m.items = append(m.items, exportedMockMenuItem{label: label})
|
|
|
|
|
m.submenus = append(m.submenus, sub)
|
|
|
|
|
return sub
|
|
|
|
|
}
|
2026-03-13 13:32:16 +00:00
|
|
|
|
|
|
|
|
type exportedMockMenuItem struct {
|
2026-04-02 13:03:55 +00:00
|
|
|
label, tooltip string
|
2026-03-13 13:32:16 +00:00
|
|
|
checked, enabled bool
|
|
|
|
|
onClick func()
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 13:03:55 +00:00
|
|
|
func (mi *exportedMockMenuItem) SetTooltip(tip string) { mi.tooltip = tip }
|
|
|
|
|
func (mi *exportedMockMenuItem) SetChecked(checked bool) { mi.checked = checked }
|
|
|
|
|
func (mi *exportedMockMenuItem) SetEnabled(enabled bool) { mi.enabled = enabled }
|
|
|
|
|
func (mi *exportedMockMenuItem) OnClick(fn func()) { mi.onClick = fn }
|
|
|
|
|
func (mi *exportedMockMenuItem) AddSubmenu() PlatformMenu { return &exportedMockMenu{} }
|