-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser_test.go
62 lines (54 loc) · 1.12 KB
/
browser_test.go
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
59
60
61
62
package kiosk
import (
"flag"
"fmt"
"testing"
)
func TestMain(m *testing.T) {
t := flag.Bool("t", false, "Run tests for all installed browsers")
flag.Parse()
if *t {
testCompatible("https://google.com")
} else {
if flag.Arg(0) == "" {
m.Error("Please supply an url as argument")
return
}
Run(flag.Arg(0))
}
}
//Run opens a browser in Kiosk mode
func Run(url string) {
list := GetInstalled() //get all installed browsers
b := BestBrowser(list) //get the best one
b.Exec(url) //run that browser with an url
}
//example usage: testSome([]string{"firefox", "chromium"}, "https://google.com")
func testSome(testing []string, url string) {
for _, b := range testing {
fmt.Println(Browsers[b].Name)
err := Browsers[b].Exec(url)
if err != nil {
fmt.Println(err)
}
}
}
func testCompatible(url string) {
testing := GetInstalled()
for _, b := range testing {
fmt.Println(b.Name)
err := b.Exec(url)
if err != nil {
fmt.Println(err)
}
}
}
func testAll(url string) {
for _, b := range Browsers {
fmt.Println(b.Name)
err := b.Exec(url)
if err != nil {
fmt.Println(err)
}
}
}