-
Notifications
You must be signed in to change notification settings - Fork 958
Expand file tree
/
Copy pathrobot_mac_test.go
More file actions
58 lines (50 loc) · 1.72 KB
/
Copy pathrobot_mac_test.go
File metadata and controls
58 lines (50 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//go:build darwin && (mac || purego)
// +build darwin
// +build mac purego
// Copyright (c) 2016-2026 AtomAI, All rights reserved.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
//
// This file may not be copied, modified, or distributed
// except according to those terms.
package robotgo_test
import (
"testing"
"github.com/go-vgo/robotgo"
)
// TestGetVerMac checks the version string on the pure-Go mac backend.
func TestGetVerMac(t *testing.T) {
if robotgo.GetVersion() != robotgo.Version {
t.Fatalf("GetVersion: got %q, want %q", robotgo.GetVersion(), robotgo.Version)
}
}
// TestColorMac exercises the color path (GetPixelColor/PadHex) on the
// pure-Go mac backend; robotgo_test.go's TestColor is excluded by -tags mac.
func TestColorMac(t *testing.T) {
// Headless / unpermissioned environments return the "000000" fallback;
// just ensure a valid 6-char hex string comes back without panicking.
c := robotgo.GetPixelColor(1, 1)
if len(c) != 6 {
t.Fatalf("GetPixelColor: got %q, want 6 hex chars", c)
}
if got := robotgo.PadHex(0xABCDEF); got != "abcdef" {
t.Fatalf("PadHex(0xABCDEF): got %q, want %q", got, "abcdef")
}
if got := robotgo.PadHex(0x123); got != "000123" {
t.Fatalf("PadHex(0x123): got %q, want %q", got, "000123")
}
}
// TestGetMainIdMac checks the main display id wrapper on the mac backend.
func TestGetMainIdMac(t *testing.T) {
id := robotgo.GetMainId()
if id < 0 {
t.Fatalf("GetMainId: got negative id %d", id)
}
if !robotgo.IsMain(id) {
t.Fatalf("IsMain(%d): expected true", id)
}
}