function ExitTest
% ExitTest
%
% Test whether Screen succeeds in cleaning up after an error.
%
% BUGS: the automatic cleanup doesn't work in Student Matlab.

% 3/31/97 dhb  Wrote it.
% 4/3/97  dgp  Added explanation.
% 4/24/97 dgp  Polished.
% 5/31/97 dgp  Polished explanation.
% 1/12/98 dgp  Noted failure in Student Matlab.
% 6/19/02 dgp  Switched emphasis to Cmd-. to make result more immediately understandable.

FlushEvents('mouseDown','mouseUp');
w=Screen(0,'OpenWindow');
Screen(w,'TextSize',18);
Screen(w,'DrawText','ExitTest tests the closing of all Screen windows that occurs',10,100);
Screen(w,'DrawText','automatically when an error is detected by any of the',10,130);
Screen(w,'DrawText','Psychophysics MEX files (e.g. hitting Cmd-. or calling SetMouse with too',10,160);
Screen(w,'DrawText','many arguments). We''ll now generate an error, which should ',10,190);
Screen(w,'DrawText','automatically dispose of this window.',10,220);
Screen(w,'DrawText','Hit Command-Period or click mouse to proceed.',10,250);
fprintf('IMPORTANT: this program is intentionally generating the follow ERROR in order to\n');
fprintf('test whether the window is automatically closed. The test is SUCCESSFUL if the window closed.\n');
GetClicks;
SetMouse('this will generate an error');
