Update to 2.0.0 tree from current Fremantle build
[opencv] / tests / swig_python / highgui / cvGetWindowHandleName.py
1 #! /usr/bin/env python
2 """
3 This script will test highgui's window handle/name functionality
4 """
5
6 # name of this test and it's requirements
7 TESTNAME = "cvGetWindowHandleName"
8 REQUIRED = ["cvNamedWindow"]
9
10  
11 # needed for sys.exit(int) and .works file handling
12 import sys
13 import works
14
15 # check requirements and delete old flag file, if it exists
16 if not works.check_files(REQUIRED,TESTNAME):
17         sys.exit(77)
18
19 # import the necessary things for OpenCV
20 from highgui import *
21 from cv import *
22
23
24 # some definitions
25 win_name = "testing..."
26
27 # create a window ( 'cvNamedWindow.works' says: "Ok, go for it!" )
28 cvNamedWindow(win_name,CV_WINDOW_AUTOSIZE)
29
30 # check if the window handle and the according name are correct
31 win_name_2 = cvGetWindowName( cvGetWindowHandle(win_name) )
32 if win_name_2!=win_name:
33 #       print "(ERROR) Incorrect window handle/name."
34         sys.exit(1)
35
36 # destroy the window
37 cvDestroyWindow( win_name )
38
39 # create flag file for following tests
40 works.set_file(TESTNAME)
41
42 # return 0 ('PASS')
43 sys.exit(0)