package tray import "testing" func TestControllerOpensWindowOnTrayDoubleClick(t *testing.T) { opened := 0 controller := newController(Config{ OnOpen: func() { opened++ }, }) handled := controller.handleTrayEvent(wmLeftButtonDoubleClick) if !handled { t.Fatal("expected tray double-click to be handled") } if opened != 1 { t.Fatalf("expected open callback to run once, got %d", opened) } } func TestControllerOpensWindowWhenTrayEventContainsIconID(t *testing.T) { opened := 0 controller := newController(Config{ OnOpen: func() { opened++ }, }) handled := controller.handleTrayEvent(wmLeftButtonDoubleClick | 1<<16) if !handled { t.Fatal("expected packed tray double-click event to be handled") } if opened != 1 { t.Fatalf("expected open callback to run once, got %d", opened) } } func TestControllerIgnoresTraySingleClick(t *testing.T) { opened := 0 controller := newController(Config{ OnOpen: func() { opened++ }, }) handled := controller.handleTrayEvent(wmLeftButtonUp) if handled { t.Fatal("expected single-click to be ignored") } if opened != 0 { t.Fatalf("expected open callback not to run, got %d calls", opened) } }