-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
61 lines (47 loc) · 1.39 KB
/
main_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
package main
import (
"strings"
"testing"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/widget"
"github.com/Uttkarsh-raj/Steg-GO/helper"
)
func TestHideTextInImage(t *testing.T) {
a := app.New()
w := a.NewWindow("Test")
image := canvas.NewImageFromFile("assets\\Logo.png")
text := widget.NewMultiLineEntry()
text.Text = "Test Data"
hiddenText := ""
helper.HideTextInImage(w, image, text, &hiddenText)
contents := strings.Split(string(hiddenText), "\n##hiddenText##: ")
expected := contents[len(contents)-1]
if expected != "Test Data" {
t.Errorf("expected %s, got %s", expected, hiddenText)
}
}
func TestExtractTextFromImage(t *testing.T) {
a := app.New()
w := a.NewWindow("Test")
image := canvas.NewImageFromFile("assets\\test_extract.jpg")
text := widget.NewMultiLineEntry()
helper.ExtractTextFromImage(w, image, text)
expected := "Hello there this is a letter to specify that i am in need\nPlease help me....."
if text.Text != expected {
t.Errorf("expected %s, got %s", expected, text.Text)
}
}
func TestResetAll(t *testing.T) {
a := app.New()
w := a.NewWindow("Test")
image := canvas.NewImageFromFile("assets\\Logo.png")
text := widget.NewMultiLineEntry()
helper.ResetAll(w, image, text)
if image.File != "" {
t.Errorf("expected empty image file, got %s", image.File)
}
if text.Text != "" {
t.Errorf("expected empty text, got %s", text.Text)
}
}