tests: Skip PSPP permissions test if permissions don't work as expected.
[pspp.git] / doc / screengrab
bloba8ee440f2f9572666714837ce0c3190f6c6c9295
1 #!/bin/bash
2 ## PSPP - a program for statistical analysis.
3 ## Copyright (C) 2020 Free Software Foundation, Inc.
4 ##
5 ## This program is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, either version 3 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
18 fail ()
20 kill $pid;
21 echo FAILED to grab image for $payload
22 cat $errfile
23 rm -f $errfile
24 exit 1;
27 pass ()
29 kill $pid;
30 rm -f $errfile
31 exit 0;
34 # Types the argument, with a pause after the first character.
35 hard_type ()
37 xdotool type "${1:0:1}"
38 xdotool sleep 0.5
39 xdotool type "${1:1}"
42 theme=Aidwaita
44 while test $# -gt 0; do
45 case "$1" in
46 --topsrcdir=*)
47 topsrcdir=${1/--topsrcdir=/}
49 --application=*)
50 application=${1/--application=/}
52 --x-server=*)
53 xserver=${1/--x-server=/}
55 --payload=*)
56 payload=${1/--payload=/}
58 --theme=*)
59 theme=${1/--theme=/}
62 output=$1;
64 esac
65 shift 1;
66 done
68 rm -f $output
69 export LC_ALL=C
71 width=1440
72 height=900
74 temp=`mktemp -d`
75 export HOME=$temp
77 mkdir -p $HOME/.config
78 cat > $HOME/.config/psppirerc <<EOF
79 [PsppireOutputWindow]
80 maximize=true
82 [PsppireDataWindow]
83 maximize=true
84 height=$height
85 width=$width
87 [PsppireSyntaxWindow]
88 maximize=true
89 EOF
92 # xserver=xephyr
94 case "$xserver" in
95 xvfb)
96 display=:$RANDOM
97 Xvfb +extension XTEST \
98 -screen 0 "$width"x"$height"x24 \
99 $display &
101 xephyr)
102 display=:$RANDOM
103 Xephyr -screen "$width"x"$height" \
104 +extension XTEST \
105 -noxv \
106 -dumb $display &
108 native)
109 display=$DISPLAY
112 printf "Unknown X server type\n";
113 exit 1;
115 esac
116 pid=$!
117 export DISPLAY=$display
118 export GTK_THEME=$theme
120 sleep 1
122 errfile=`mktemp`
123 $application -q -n 2> $errfile &
124 if test "$xserver"x = "native"x; then pid=$!; fi
126 xdotool sleep 0.5
127 if test $? -ne 0 ; then fail; fi
129 trap fail ERR
130 . $payload
132 mv $output,tmp $output
133 pass;