File: gxtest

package info (click to toggle)
gxmessage 3.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,232 kB
  • sloc: sh: 1,565; ansic: 819; makefile: 46
file content (84 lines) | stat: -rw-r--r-- 2,518 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
# gxmessage tests and examples

# use xmessage if gxmessage isn't available
XMESSAGE=${XMESSAGE:-$(which gxmessage)} || MESSAGE=xmessage
XMESSAGE=$(basename "$XMESSAGE")

$XMESSAGE A few $XMESSAGE tests
$XMESSAGE -center "The -center option"
$XMESSAGE -center -default okay "The default button has focus"

$XMESSAGE -center -buttons "one:1,two:2,three:3" \
  "Button labels and return values"
echo $?

$XMESSAGE -center -buttons 'Hello\, world:42,This\, as you see\, is a test:43' \
  "Buttons containing escaped characters"
echo $?

$XMESSAGE -center -print -buttons 'one\: 10:10,two\: 20:20,three\: 30:30,hello\, world\: 40:40' \
  "More buttons with escaped characters"

$XMESSAGE -center \
  -buttons "GTK_STOCK_HELP,GTK_STOCK_OK,GTK_STOCK_CANCEL,GTK_STOCK_CLOSE" \
  -default GTK_STOCK_CLOSE "Some GTK stock buttons"
echo $?

$XMESSAGE -center -buttons "" -timeout 3 "The -timeout option..."
echo $?

$XMESSAGE -center -buttons "_Red,_Green,_Blue" -default _Blue \
  "Keyboard accelerators (try pressing ALT to see them)"

$XMESSAGE -center -file "$0" -default okay

echo "geometry +100+100"
$XMESSAGE -help | $XMESSAGE -file - -default okay -geom +100+100

echo "geometry -0-0"
$XMESSAGE -help | $XMESSAGE -file - -default okay -geom -0-0

echo "geometry 300x300+100+100"
$XMESSAGE -help | $XMESSAGE -file - -default okay -geom 300x300+100+100

echo "automatic geometry"
$XMESSAGE -help | $XMESSAGE -center -file - -default okay

$XMESSAGE -center -fg white -bg '#10191e' -default okay \
  "The -fg and -bg options"

FONT="monospace bold 12"
[ "$XMESSAGE" = gxmessage ] || FONT="-misc-fixed-*-*-*-*-*-140-*-*-*-*-*-*"
$XMESSAGE -center -geometry 500x100 ${FONT:+-font "$FONT"} \
  "Using -font without upsetting xmessage"

$XMESSAGE - -- dash - test - -- -center - -default okay -

$XMESSAGE -center -display :0 "Testing the -display and -name options" \
          -name George

echo "Feeding gxmessage a super long button label should cause it to quit with a warning and an exit code of 1, rather than crash in flames..."
$XMESSAGE "Some text" -buttons $(python -c "print 'A'*115000")
echo "The exit code was: $?"

if [ "$XMESSAGE" != gxmessage ]
then

  # skip gxmessage-specific tests if not using gxmessage
  :

else

  NAME=$($XMESSAGE -center -entry -buttons "" "What's your name?")
  echo "Hello, $NAME!"

  ME=${HOSTNAME:-Bart}
  NAME=$($XMESSAGE -center -entrytext "$ME" -buttons "" \
         "What's my name?");
  [ "$NAME" = "$ME" ] || echo "You mean I'm not $ME?!"

fi

echo "finished"