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
|
//go:build !android
package main
import "testing"
func TestReadSharedFromCacheStub(t *testing.T) {
txt, err := readSharedFromCache()
if err != nil {
t.Fatalf("stub returned error: %v", err)
}
if txt != "" {
t.Errorf("stub returned non-empty text: %q", txt)
}
}
func TestHandleSharedTextLoadAutoLogSkipsEmptyStubText(t *testing.T) {
var clearCalls int
handleSharedTextLoad(
"",
true,
t.TempDir(),
func(string) {
t.Fatal("prefill should not be called for empty shared text")
},
func() {
t.Fatal("focus should not be called for empty shared text")
},
func() {
t.Fatal("resetInput should not be called for empty shared text")
},
func() {
clearCalls++
},
func(string, string) error {
t.Fatal("logEntry should not be called for empty shared text")
return nil
},
func(string, string) {
t.Fatal("info dialog should not be shown for empty shared text")
},
func(error) {
t.Fatal("error dialog should not be shown for empty shared text")
},
)
if clearCalls != 1 {
t.Fatalf("expected cache cleanup once, got %d", clearCalls)
}
}
|