-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_button_test.go
80 lines (75 loc) · 9.21 KB
/
input_button_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package dosktop
import (
"github.com/supercom32/dosktop/internal/memory"
"github.com/supercom32/dosktop/internal/recast"
"github.com/stretchr/testify/assert"
"testing"
)
func TestUpdateButtonState(test *testing.T) {
commonResource.isDebugEnabled = true
layerAlias1 := "Layer1"
layerAlias2 := "Layer2"
layerWidth := 40
layerHeight := 20
buttonAlias1 := "Button1"
buttonAlias2 := "Button2"
styleEntry := memory.NewTuiStyleEntry()
InitializeTerminal(layerWidth, layerHeight)
AddLayer(layerAlias1, 0, 0, layerWidth, layerHeight, 1, "")
AddLayer(layerAlias2, 3, 2, 30, 20, 2, layerAlias1)
Layer(layerAlias1)
Color(4, 6)
FillLayer(layerAlias1, "a1a2a3a4a5")
Layer(layerAlias2)
Color(3, 11)
FillLayer(layerAlias2, "b1b2b3b4b5")
memory.AddButton(layerAlias2, buttonAlias1, "ButtonText", styleEntry, 2, 2, 20, 7)
memory.AddButton(layerAlias2, buttonAlias2, "ButtonText", styleEntry, 2, 10, 20, 7)
memory.MouseMemory.SetMouseStatus(10, 5, uint(1), "")
UpdateDisplay() // Must be done first to update the shared display.
updateButtonStates()
obtainedValue := memory.ButtonMemory[layerAlias2][buttonAlias1].IsPressed
expectedValue := true
assert.Equalf(test, expectedValue, obtainedValue ,"The button pressed state was not detected as expected!")
memory.MouseMemory.SetMouseStatus(10, 5, 0, "")
updateButtonStates()
obtainedValue = memory.ButtonMemory[layerAlias2][buttonAlias1].IsPressed
expectedValue = false
assert.Equalf(test, expectedValue, obtainedValue ,"The button pressed state was not detected as expected!")
UpdateDisplay()
}
func TestGetButtonClickIdentifier(test *testing.T) {
commonResource.isDebugEnabled = true
layerAlias1 := "Layer1"
layerAlias2 := "Layer2"
layerWidth := 40
layerHeight := 20
buttonAlias1 := "Button1"
buttonAlias2 := "Button2"
styleEntry := memory.NewTuiStyleEntry()
InitializeTerminal(layerWidth, layerHeight)
AddLayer(layerAlias1, 0, 0, layerWidth, layerHeight, 1, "")
AddLayer(layerAlias2, 3, 2, 30, 20, 2, layerAlias1)
Layer(layerAlias1)
Color(4, 6)
FillLayer(layerAlias1, "a1a2a3a4a5")
Layer(layerAlias2)
Color(3, 11)
FillLayer(layerAlias2, "b1b2b3b4b5")
memory.AddButton(layerAlias2, buttonAlias1, "ButtonText", styleEntry, 2, 2, 20, 7)
memory.AddButton(layerAlias2, buttonAlias2, "ButtonText", styleEntry, 2, 10, 20, 7)
memory.ButtonMemory[layerAlias2][buttonAlias2].IsPressed = true
UpdateDisplay()
layerEntry := commonResource.screenLayer
obtainedValue := layerEntry.GetBasicAnsiStringAsBase64()
expectedValue := "G1szODsyOzA7MDsxMjhtG1s0ODsyOzA7MTI4OzEyOG1hMWEyYTNhNGE1YTFhMmEzYTRhNWExYTJhM2E0YTVhMWEyYTNhNGE1G1szODsyOzA7MDswbRtbNDg7MjswOzA7MG0KG1szODsyOzA7MDsxMjhtG1s0ODsyOzA7MTI4OzEyOG1hMWEyYTNhNGE1YTFhMmEzYTRhNWExYTJhM2E0YTVhMWEyYTNhNGE1G1szODsyOzA7MDswbRtbNDg7MjswOzA7MG0KG1szODsyOzA7MDsxMjhtG1s0ODsyOzA7MTI4OzEyOG1hMWEbWzM4OzI7MTI4OzEyODswbRtbNDg7MjsyNTU7MjU1OzBtYjFiMmIzYjRiNWIxYjJiM2I0YjViMWIyYjNiNGI1G1szODsyOzA7MDsxMjhtG1s0ODsyOzA7MTI4OzEyOG0yYTNhNGE1G1szODsyOzA7MDswbRtbNDg7MjswOzA7MG0KG1szODsyOzA7MDsxMjhtG1s0ODsyOzA7MTI4OzEyO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tYTFhG1szODsyOzEyODsxMjg7MG0bWzQ4OzI7MjU1OzI1NTswbWIxYjJiM2I0YjViMWIyYjNiNGI1YjFiMmIzYjRiNRtbMzg7MjswOzA7MTI4bRtbNDg7MjswOzEyODsxMjhtMmEzYTRhNRtbMzg7MjswOzA7MG0bWzQ4OzI7MDswOzBtCg=="
assert.Equalf(test, expectedValue, obtainedValue ,"The updated screen does not match the master original!")
obtainedLayerAlias, obtainedButtonAlias := getButtonClickIdentifier(10, 5)
obtainedValue2 := recast.GetArrayOfInterfaces(obtainedLayerAlias, obtainedButtonAlias)
expectedValue2 := recast.GetArrayOfInterfaces(layerAlias2, buttonAlias1)
assert.Equalf(test, expectedValue2, obtainedValue2 ,"The layer and button alias obtained did not match what was expected!")
obtainedLayerAlias, obtainedButtonAlias = getButtonClickIdentifier(10, 13)
obtainedValue2 = recast.GetArrayOfInterfaces(obtainedLayerAlias, obtainedButtonAlias)
expectedValue2 = recast.GetArrayOfInterfaces(layerAlias2, buttonAlias2)
assert.Equalf(test, expectedValue2, obtainedValue2 ,"The layer and button alias obtained did not match what was expected!")
}