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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
#!/bin/bash
#
# test-interaction.sh
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ====
#
# Launches a number of window types, and then via 'xnee' automates
# common user interactions. Useful when running with valgrind.
#
# A screenshot is taken of the end result and compared to an earlier
# saved correct result. If there's a diffence, the original and new
# screenshot are shown using 'display' and test failed.
# XXX not needed anymore as we use xnest-geom for multi setups.
#if [ -z "$(xdpyinfo | grep dimensions: | grep 240x320)" ]; then
# echo "$0: Display must be 240x320 for event playback to work correctly"
# exit 2 # 2 indicates mis-setup
#fi
source ./test.conf
if [ -z "$XNEST_GEOM" ]; then
echo "*Warning* XNEST_GEOM not set, assuming 240x320"
XNEST_GEOM=240x320
fi
if [ -z $(which xnee|grep "/xnee") ]; then
echo "$0: 'xnee' required for event automation is missing"
exit 2
fi
#if [ -z $(which xwd|grep "/xwd") ]; then
# echo "$0: 'xwd' required for test result comparison is missing"
# exit 2
#fi
if [ \! -x winspew ]; then
echo "$0: 'winspew' test utility missing, compile it first!"
exit 2
fi
if [ ! -f "test-interaction-$XNEST_GEOM.xnee" ]; then
echo "$0: test-interaction-$XNEST_GEOM.xnee playback data missing"
# exit 2
fi
if [ ! -f "test-interaction-$XNEST_GEOM.xwd" ]; then
echo "$0: test-interaction-$XNEST_GEOM.xwd comparison image missing"
# exit 2
fi
# mbtest theme now used.
# mbtest theme *must* be installed or test will likely fail.
matchbox-remote -t mbtest
if [ -z $(which matchbox-desktop) ]; then
echo "$0: please install matchbox-desktop for running this test!"
fi
if [ -z $(which gedit) ]; then
echo "$0: please install gedit for running this test!"
fi
# Launch various window types.
matchbox-desktop &
sleep 1
# gedit is really needed to push some of the ewmh stuff
gedit &
sleep 1
./winspew -np -t "Window",normal 2>&1 > /dev/null &
sleep 1
./winspew -np -t "Window",dock,+0+300 2>&1 > /dev/null &
sleep 1
./winspew -np -t "Window",toolbar 2>&1 > /dev/null &
sleep 1
## Add some sleeps to avoid race where final display order can differ...
sleep 1
./winspew -np -t "Window",normal -c "Dialog",160x110 -c "Dialog",100x100 2>&1 > /dev/null &
sleep 1
./winspew -np -t "Window",normal -c "Dialog",160x150,accept_button:help_button 2>&1 > /dev/null &
# Now playback recorded interactions with Xnee.
#
# To create your own 'recording', use something like the below with
# ctrl-c to stop.
#
#
#xnee -rec -ae -o test-interaction-640x480.xnee -l -1
#
#exit
xnee -rep -fp -f test-interaction-$XNEST_GEOM.xnee 2>&1 > /dev/null
# hack.. sleep for a couple of seconds and fire a xrefresh
# maybe some xnee events still queued ..
sleep 2 && xrefresh
#
# This screenshot stuff is pretty experimental....
#
ret=""
function file_compare ()
{
if [ \! -f $1 ]; then
ret="ERROR: file '$1' missing"
return
fi
if [ \! -f $2 ]; then
ret="ERROR: file '$2' missing"
return
fi
a=$(cat $1|wc -c)
b=$(cat $2|wc -c)
if [ $a -eq $b ]; then
cmp --verbose $1 $2 > $LOGS/cmp.log
if [ $(cat $LOGS/cmp.log|wc -l) -eq 0 ]; then
# files are exact matches
ret=""
else
ret="ERROR: Files differ!\n see '$1', '$2', '$LOGS/cmp.log'"
fi
else
ret="ERROR: File sizes differ!\n$(ls -s $1 $2)\nDoes your display have correct bit-depth?"
fi
}
if [ -z "$WANT_IMG_COMPARE" ]; then
killall winspew matchbox-desktop
exit 0
fi
echo "$0: grabbing screenshot..."
SHOT=$LOGS/out.xwd
rm -f $SHOT
#xwd -root -out ./test-interaction.xwd
xwd -root -out $SHOT
killall winspew matchbox-desktop gedit
file_compare ./test-interaction-$XNEST_GEOM.xwd $SHOT
if [ -z "$ret" ]; then
echo "$0: Test Succeeded"
exit 0
else
echo -e "$0: Test Failed - $ret"
if [ \! -z $(which display|grep "/display") ]; then
# assumes the main display is :0, and shows the screenshots there
# using 'display' from ImageMagick package
DISPLAY=:0 display -title "Correct: ./test-interaction-$XNEST_GEOM.xwd" ./test-interaction-$XNEST_GEOM.xwd &
DISPLAY=:0 display -title "Failure: $SHOT" $SHOT &
echo "(the correct and failed image are now shown using 'display')"
fi
exit 1
fi
|