44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/sha256"
|
|
"fmt"
|
|
"image/png"
|
|
"testing"
|
|
)
|
|
|
|
func TestTrayMouseButtonsAndKeyboard(t *testing.T) {
|
|
for _, event := range []uint32{0x400, 0x401, 0x7b, 0x208, 0x20c} {
|
|
if !trayActivation(true, event) {
|
|
t.Fatalf("version 4 activation missing: %#x", event)
|
|
}
|
|
}
|
|
for _, event := range []uint32{0x202, 0x205, 0x208, 0x20c} {
|
|
if !trayActivation(false, event) {
|
|
t.Fatalf("legacy activation missing: %#x", event)
|
|
}
|
|
}
|
|
for _, event := range []uint32{0x202, 0x205, 0x200, 0} {
|
|
if trayActivation(true, event) {
|
|
t.Fatalf("duplicate or spurious version 4 activation: %#x", event)
|
|
}
|
|
}
|
|
}
|
|
func TestEmbeddedOfficialSilkAssets(t *testing.T) {
|
|
for _, test := range []struct {
|
|
data []byte
|
|
hash string
|
|
}{{trayPNG, "f52dca6b882152f3a4f2459ea8a02a75a6d925bf18082cae31bb0ecc254fb9eb"}, {exitPNG, "d04ecfc93ff86c44f6fc39e35945e3d8a7648ba8fcd97a2635920df2e88893b3"}} {
|
|
if fmt.Sprintf("%x", sha256.Sum256(test.data)) != test.hash {
|
|
t.Fatal("asset differs from pinned official repository")
|
|
}
|
|
config, err := png.DecodeConfig(bytes.NewReader(test.data))
|
|
if err != nil || config.Width != 16 || config.Height != 16 {
|
|
t.Fatal("invalid Silk image", err)
|
|
}
|
|
}
|
|
}
|