File: test_dialog_message.pro

package info (click to toggle)
gnudatalanguage 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,832 kB
  • sloc: cpp: 198,435; ansic: 47,740; sh: 691; python: 474; makefile: 149; xml: 69; f90: 28
file content (81 lines) | stat: -rw-r--r-- 2,983 bytes parent folder | download | duplicates (6)
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
;
; Under GNU GPL v2 or later
; Alain Coulais, 15-Nov-2012
;
; **interactif** test of revised DIALOG_MESSAGE
;
; ------------------------------------
;
pro TEST_DIALOG_MESSAGE, no_exit=no_exit, help=help, test=test
;
if KEYWORD_SET(help) then begin
   print, 'pro TEST_DIALOG_MESSAGE, no_exit=no_exit, help=help, test=test'
   return
end
;
nb_errors=0
;
expected='OK'
result=DIALOG_MESSAGE('would you like to continue ?')
if (result NE expected) then ERRORS_ADD, 'Error case 1', nb_errors
;
result=DIALOG_MESSAGE('would you like to continue ?',/error)
if (result NE expected) then ERRORS_ADD, 'Error case 1 /Error', nb_errors
;
result=DIALOG_MESSAGE('would you like to continue ?',/information)
if (result NE expected) then  ERRORS_ADD, 'Error case 1 /Information', nb_errors
;
; with /Cancel keyword, case OK to be clicked
;
expected='OK'
result=DIALOG_MESSAGE('Please press OK/Yes',/cancel)
if (result NE expected) then ERRORS_ADD, 'Error case 2 with /cancel', nb_errors
;
result=DIALOG_MESSAGE('Please press OK/Yes',/error,/cancel)
if (result NE expected) then ERRORS_ADD, 'Error case 2 /Error with /cancel', nb_errors
;
result=DIALOG_MESSAGE('Please press OK/Yes',/information,/cancel)
if (result NE expected) then  ERRORS_ADD, 'Error case 2 /Information with /cancel', nb_errors
;
; with /Cancel keyword, case CANCEL to be clicked
;
expected='Cancel'
result=DIALOG_MESSAGE('Please press CANCEL',/cancel)
if (result NE expected) then ERRORS_ADD, 'Error case 3 with /cancel', nb_errors
;
result=DIALOG_MESSAGE('Please press CANCEL',/error,/cancel)
if (result NE expected) then ERRORS_ADD, 'Error case 3 /Error with /cancel', nb_errors
;
result=DIALOG_MESSAGE('Please press CANCEL',/information,/cancel)
if (result NE expected) then  ERRORS_ADD, 'Error case 3 /Information with /cancel', nb_errors
;
; QUESTION without /Cancel keyword, responses are in {"Yes","No"[,"Cancel"]}
;
expected='Yes'
result=DIALOG_MESSAGE('Please press YES',/question)
if (result NE expected) then ERRORS_ADD, 'Error case 4 with /question', nb_errors
;
expected='No'
result=DIALOG_MESSAGE('Please press NO',/question)
if (result NE expected) then ERRORS_ADD, 'Error case 4 with /question', nb_errors
;
expected='Yes'
result=DIALOG_MESSAGE('Please press Yes',/question, /Cancel)
if (result NE expected) then ERRORS_ADD, 'Error case 5 [Yes] with /question and /cancel', nb_errors
expected='No'
result=DIALOG_MESSAGE('Please press NO',/question, /Cancel)
if (result NE expected) then ERRORS_ADD, 'Error case 5 [No] with /question and /cancel', nb_errors
expected='Cancel'
result=DIALOG_MESSAGE('Please press Cancel',/question, /Cancel)
if (result NE expected) then ERRORS_ADD, 'Error case 5 [Cancel] with /question and /cancel', nb_errors
;
if (nb_errors EQ 0) then begin
   MESSAGE, /continue, 'All TEST_DIALOG_MESSAGE tests successful'
endif else begin
   MESSAGE, /continue, STRING(nb_errors)+' tests failed'
   if ~KEYWORD_SET(no_exit) then EXIT, status=1
endelse
;
if KEYWORD_SET(test) then STOP
;
end