1; 2; AC 18/10/2009 under GNU/GPL 2 or later 3; 4; resived 03/05/2010 for integration in the "make check" testsuite 5; 6; purpose: quickly testing the GET_SCREEN_SIZE() function 7; 8; --------------------------------------------------- 9; 10pro DEMO_GET_SCREEN_SIZE 11; 12sep = '==============================' 13; 14print, sep 15print, 'basic test (call without Display name)' 16taille=GET_SCREEN_SIZE(resolution=resolution) 17print, 'Screen Size (in pixels) :', taille 18print, 'Pixel Size (in mm) :', resolution 19; 20print, sep 21SPAWN, 'echo $DISPLAY', display 22print, 'On current Display, using "'+display+'" as name' 23taille=GET_SCREEN_SIZE(display, resolution=resolution) 24print, 'Screen Size (in pixels) :', taille 25print, 'Pixel Size (in mm) :', resolution 26; 27print, sep 28print, 'On current Display, using ":0" as name' 29print, '(may give <<Xlib: connection to ":0.0" refused by server>> on remote)' 30display=':0' 31taille=GET_SCREEN_SIZE(display, resolution=resolution) 32print, 'Screen Size (in pixels) :', taille 33print, 'Pixel Size (in mm) :', resolution 34;; 35print, sep 36; 37end 38; 39; --------------------------------------------------- 40; 41pro TESTING_GET_SCREEN_SIZE, cumul_errors, test=test 42; 43nb_errors=0 44; 45print, 'basic test (call without Display name)' 46taille=GET_SCREEN_SIZE(resolution=resolution) 47print, 'Screen Size (in pixels) :', taille 48print, 'Pixel Size (in mm) :', resolution 49; 50; are the values "reasonables" ? 51; 1/ positives values 52; 2/ (non blocking) quasi square pixels 53; 3/ (non blocking) non excessive aspect ratio for the whole screen 54; 55nb_doubts=0 56nb_pbs=0 57if (taille[0] LE 0) then $ 58 ERRORS_ADD, nb_errors, 'Error, screen length < 0' 59if (taille[1] LE 0) then $ 60 ERRORS_ADD, nb_errors, 'Error, screen height < 0' 61if (resolution[0] LE 0) then $ 62 ERRORS_ADD, nb_errors, 'Error, length resolution < 0' 63if (resolution[1] LE 0) then $ 64 ERRORS_ADD, nb_errors, 'Error, height resolution < 0' 65; 66pixel_aspect_ratio=resolution[1]/resolution[0] 67if ((pixel_aspect_ratio LT 0.95) OR (pixel_aspect_ratio GT 1.05)) then begin 68 ERRORS_ADD, nb_errors, 'the pixels of this screen are not square !' 69endif 70; 71screen_aspect_ratio=float(taille[1])/float(taille[0]) 72if ((screen_aspect_ratio LT 0.5) OR (screen_aspect_ratio GT 2.)) then begin 73 ERRORS_ADD, nb_errors, 'this screen has strange aspect ratio !! (< 0.5 or > 2)' 74endif 75; 76if (~ISA(taille, 'Long')) then begin 77 ERRORS_ADD, nb_errors, 'The return value is not a "Long" type !' 78endif 79; 80BANNER_FOR_TESTSUITE, 'TESTING_GET_SCREEN_SIZE', nb_errors, /status 81ERRORS_CUMUL, cumul_errors, nb_errors 82if KEYWORD_SET(test) then STOP 83; 84end 85; 86; --------------------------------------------------- 87; 88pro TEST_GET_SCREEN_SIZE, help=help, no_exit=no_exit, test=test 89; 90if KEYWORD_SET(help) then begin 91 print, 'pro TEST_GET_SCREEN_SIZE, help=help, no_exit=no_exit, test=test' 92 return 93endif 94; 95if GETENV('DISPLAY') eq '' then begin 96 ERRORS_ADD, nb_errors, 'apparently no X connection is available (DISPLAY env. var. not set)' 97 EXIT, status=77 98endif 99; 100TESTING_GET_SCREEN_SIZE, nb_errors, test=test 101; 102BANNER_FOR_TESTSUITE, 'TEST_GET_SCREEN_SIZE', nb_errors 103; 104if (nb_errors GT 0) AND ~KEYWORD_SET(no_exit) then EXIT, status=1 105; 106if KEYWORD_SET(test) then STOP 107; 108end 109