|
|
@@ -82,7 +82,7 @@ func TestCatalogDefaultEffectPerChannel(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestResolveEffectWithoutACatalogRefuses(t *testing.T) {
|
|
|
- _, _, err := ResolveEffect(nil, "wave", []via.Channel{via.ChannelRgblight})
|
|
|
+ _, _, err := ResolveEffect(nil, "wave", []via.Channel{via.ChannelRgblight}, false)
|
|
|
if err == nil {
|
|
|
t.Fatal("ResolveEffect(nil, ...) expected an error, got nil")
|
|
|
}
|
|
|
@@ -96,7 +96,7 @@ func TestResolveEffectWithoutACatalogRefuses(t *testing.T) {
|
|
|
func TestResolveEffectSkipsAChannelThatDoesNotSupportTheName(t *testing.T) {
|
|
|
catalog := impact80(t)
|
|
|
|
|
|
- targets, skipped, err := ResolveEffect(catalog, "light", []via.Channel{via.ChannelRgblight, via.ChannelRgbMatrix})
|
|
|
+ targets, skipped, err := ResolveEffect(catalog, "light", []via.Channel{via.ChannelRgblight, via.ChannelRgbMatrix}, false)
|
|
|
if err != nil {
|
|
|
t.Fatalf("ResolveEffect() error = %v", err)
|
|
|
}
|
|
|
@@ -113,7 +113,7 @@ func TestResolveEffectSkipsAChannelThatDoesNotSupportTheName(t *testing.T) {
|
|
|
func TestResolveEffectRejectsTheOnlyChannelWhenItDoesNotSupportTheName(t *testing.T) {
|
|
|
catalog := impact80(t)
|
|
|
|
|
|
- _, _, err := ResolveEffect(catalog, "light", []via.Channel{via.ChannelRgbMatrix})
|
|
|
+ _, _, err := ResolveEffect(catalog, "light", []via.Channel{via.ChannelRgbMatrix}, true)
|
|
|
if err == nil {
|
|
|
t.Fatal("ResolveEffect() expected an error, want light rejected on the backlight")
|
|
|
}
|
|
|
@@ -122,7 +122,55 @@ func TestResolveEffectRejectsTheOnlyChannelWhenItDoesNotSupportTheName(t *testin
|
|
|
func TestResolveEffectRejectsANameNoChannelKnows(t *testing.T) {
|
|
|
catalog := impact80(t)
|
|
|
|
|
|
- if _, _, err := ResolveEffect(catalog, "nope", []via.Channel{via.ChannelRgblight}); err == nil {
|
|
|
+ if _, _, err := ResolveEffect(catalog, "nope", []via.Channel{via.ChannelRgblight}, true); err == nil {
|
|
|
t.Fatal("ResolveEffect() expected an error for an unknown name")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// "static" is a documented alias. It must resolve through every caller, not
|
|
|
+// only the one that rewrites the string before calling: the backlight catalog
|
|
|
+// spells its solid effect solid_color, so the alias chain needs both steps.
|
|
|
+func TestResolveEffectAcceptsTheStaticAliasOnEveryPath(t *testing.T) {
|
|
|
+ catalog := impact80(t)
|
|
|
+
|
|
|
+ for _, ch := range []via.Channel{via.ChannelRgblight, via.ChannelRgbMatrix, via.ChannelAudio} {
|
|
|
+ targets, _, err := ResolveEffect(catalog, "static", []via.Channel{ch}, true)
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("ResolveEffect(static on channel %d) error = %v", ch, err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if len(targets) != 1 {
|
|
|
+ t.Errorf("ResolveEffect(static on channel %d) = %d targets, want 1", ch, len(targets))
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Whether a command may skip an unsupported effect is the caller's knowledge,
|
|
|
+// not something the channel count can tell it. A board with a single lighting
|
|
|
+// channel and no --zone must still behave like a default command.
|
|
|
+func TestResolveEffectDistinguishesExplicitFromDefault(t *testing.T) {
|
|
|
+ catalog := impact80(t)
|
|
|
+ both := []via.Channel{via.ChannelRgblight, via.ChannelRgbMatrix}
|
|
|
+
|
|
|
+ // Default command, one channel cannot do it: skipped, not refused.
|
|
|
+ targets, skipped, err := ResolveEffect(catalog, "rainbow_moving_chevron", both, false)
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("default command error = %v, want the unsupported channel skipped", err)
|
|
|
+ }
|
|
|
+ if len(skipped) != 1 || skipped[0] != "rgblight" {
|
|
|
+ t.Errorf("skipped = %v, want [rgblight]", skipped)
|
|
|
+ }
|
|
|
+ if len(targets) != 1 || targets[0].Channel != via.ChannelRgbMatrix {
|
|
|
+ t.Errorf("targets = %+v, want the backlight only", targets)
|
|
|
+ }
|
|
|
+
|
|
|
+ // Same name, named channel only: refused.
|
|
|
+ if _, _, err := ResolveEffect(catalog, "rainbow_moving_chevron", []via.Channel{via.ChannelRgblight}, true); err == nil {
|
|
|
+ t.Error("explicit request error = nil, want it refused")
|
|
|
+ }
|
|
|
+
|
|
|
+ // A name no channel of this board has is unknown either way.
|
|
|
+ if _, _, err := ResolveEffect(catalog, "rainbow_moving_chevron", []via.Channel{via.ChannelRgblight}, false); err == nil {
|
|
|
+ t.Error("single-channel default command error = nil, want an unknown name reported")
|
|
|
+ }
|
|
|
+}
|