
    q'VeS                        d Z ddlZddlZddlmZmZmZmZmZm	Z	m
Z
 ddlmZ d Zd Zd Zd Zd	 Zej                            eo ej        d
          d          d             Zej                            ej        dk    oej        dd         dk    d          d             Zej                            epe d          d             Zd ZdS )zTest QtGui.    N)PYQT5PYQT_VERSIONPYSIDE2PYSIDE6QtCoreQtGui	QtWidgets)not_using_condac                 j   t           j        j        J t           j        j        J t          j        dd          }t          j        |          }t          j        |          }|                    d          }|                    d          }|t          dd          v sJ d|cxk    rdk    sn J dS )	z)Test QFontMetrics and QFontMetricsF widthNtimes   Test(   >   '   ?   )r   QFontMetricswidthQFontMetricsFQFontrange)qtbotfontfont_metricsfont_metricsFr   widthFs         5lib/python3.11/site-packages/qtpy/tests/test_qtgui.pytest_qfontmetrics_widthr      s    #///$000;w##D%d++L'--Mv&&E  ((FE"bMM!!!!2    c                 |    t           j        j        J t          j        d          }|                                 dS )z'Test functions mapping for QtGui.QDrag.N)r   QDragexec_)r   drags     r   test_qdrag_functionsr$       s3    ;(((;tDJJLLLLLr   c                     t           j        j        J t           j                                        p$t          j        t          j        t          g          } | J t          j        	                    dt           j                                        j
                   t           j                                         t           j                                        p$t          j        t          j        t          g          } | J t          j        	                    dt           j                                        j
                   |                                  dS )z"Test `QtGui.QGuiApplication.exec_`Nd   )r   QGuiApplicationr"   instancesys
executable__file__r   QTimer
singleShotquit)apps    r   test_QGuiApplication_exec_r0   '   s    &222


(
(
*
* e.C	"/ /C ???
MS%"7"@"@"B"B"GHHH	!!!


(
(
*
* e.C	"/ /C ???
MS%"7"@"@"B"B"GHHHIIKKKKKr   c                      t           j        J t           j        J t           j        J t           j        J t           j        J dS )z(Test what has been moved to QtGui in Qt6N)r   QActionQActionGroupQFileSystemModel	QShortcutQUndoCommand r   r   test_what_moved_to_qtgui_in_qt6r8   8   sQ    =$$$)))!---?&&&)))))r   c                     t           j        j        J t          j        d          }| \  }}|                    |           |                                sJ dS )z/Test functions mapping for QtGui.QTextDocument.Nr   )r   QTextDocumentprint_exists)
pdf_writertext_documentprint_deviceoutput_paths       r   test_qtextdocument_functionsrA   A   s`    %111'//M *L+&&&r   z5.9zaA specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.*to work with scoped enum access)reasonc                  ^   t           j        j        t           j        j        j        k    sJ t           j        j        t           j        j        j        k    sJ t           j        j        t           j        j	        j        k    sJ t           j
        j        t           j
        j        j        k    sJ dS )z:Test scoped and unscoped enum access for qtpy.QtWidgets.*.N)r   QColorRgbSpecr   AllUppercaseCapitalizationQIconNormalModeQImageFormat_InvalidFormatr7   r   r   test_enum_accessrO   J   s     <u|044444;#u{'A'NNNNN;!1!88888<&%,*=*LLLLLLLr   darwin   )      z"Stalls on macOS CI with Python 3.7c                     G d dt           j                  } |            }|                    dd           |                                 |                     |          5  |                     |t          j        dd                     |                     |t          j	        j
                   ddd           n# 1 swxY w Y   dD ],}d	D ]'}t          t          t          |          |          sJ (-d
D ]}t          t          j        |          sJ dD ],}dD ]'}t          t          t          |          |          sJ (-dS )z
    Test `QMouseEvent.pos` and related functions removed in Qt 6,
    and `QMouseEvent.position`, etc., missing from Qt 5.
    c                   (    e Zd Zdej        ddfdZdS )2test_QSomethingEvent_pos_functions.<locals>.WindoweventreturnNc                 H   |                                 |                                z
  |                     t          j        dd                    k    sJ |                                                                |                                k    sJ |                                                                |                                k    sJ |                                                                 |                                k    sJ |                                                                 |                                k    sJ |	                                                                |                                                                k    sJ |	                                                                |                                                                k    sJ |
                                                                |                                                                 k    sJ |
                                                                |                                                                 k    sJ |                                 d S )Nr   )	globalPosposmapToParentr   QPointxyglobalXglobalYpositionglobalPositionaccept)selfrW   s     r   mouseDoubleClickEventzHtest_QSomethingEvent_pos_functions.<locals>.Window.mouseDoubleClickEventb   s    ??$$uyy{{2d6F6Fa##7 7     99;;==??eggii////99;;==??eggii////??$$&&((EMMOO;;;;??$$&&((EMMOO;;;;>>##%%''599;;==??::::>>##%%''599;;==??::::''))++--1B1B1D1D1F1FFFFF''))++--1B1B1D1D1F1FFFFFLLNNNNNr   )__name__
__module____qualname__r   QMouseEventrf   r7   r   r   WindowrV   a   s9        	u/@ 	T 	 	 	 	 	 	r   rk   i@     *   6   N)QNativeGestureEventQEnterEventQTabletEvent)r[   r^   r_   rZ   r`   ra   rb   rc   )r[   r^   r_   rb   )
QDropEventQDragMoveEventQDragEnterEvent)r[   posFrb   )r	   QMainWindowsetMinimumSizeshowwaitExposed	mouseMover   r]   mouseDClickQt
LeftButtonhasattrgetattrr   QHoverEvent)r   rk   window_class	_functions        r   "test_QSomethingEvent_pos_functionsr   W   s       &     VXXF
#s###
KKMMM			6	"	" 8 8b% 8 8999&&)"67778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 I > >	
 
	> 
	>I 75&119======
	> 3 5 5	u()444444 F > >4 	> 	>I75&119======	>> >s   "AB==CCzPySide{2,6} specific testc                  z   t          j        d          } t          j        |           }|                    t           j        j                  rJ |                    t           j        j        t           j        j                  sJ |                                dk    sJ |                    t           j        j                  sJ |                    t           j        j        dt           j        j                  sJ |                                dk    sJ |                    t           j        j                  sJ |	                                |
                                k    sJ |                    t           j        j        t           j        j        d          sJ |                                dk    sJ dS )	z+Test monkeypatched QTextCursor.movePositionzfoo bar baz)modefoorQ   )nr   zfoo bar rR   N)r   r:   QTextCursormovePositionStart	EndOfWord
KeepAnchorselectedText	WordRightrb   anchorNextWord)doccursors     r   test_qtextcursor_movepositionr      s    
m
,
,Cs##F""5#4#:;;;;;#)         E))))u0677777#
)      
   J....u0677777??////"$	    
   M111111r   c                     t           j        J t           j        J t           j        J t           j        J t           j        J t           j        J t           j        J t           j        J t           j	        J t           j
        J t           j        J t           j        J t           j        J t           j        J t           j        J dS )z
    Test for presence of QOpenGL* classes.

    These classes were members of QtGui in Qt5, but moved to QtOpenGL in Qt6.
    QtPy makes them available in QtGui to maintain compatibility.
    N)r   QOpenGLBufferQOpenGLContextQOpenGLContextGroupQOpenGLDebugLoggerQOpenGLDebugMessageQOpenGLFramebufferObjectQOpenGLFramebufferObjectFormatQOpenGLPixelTransferOptionsQOpenGLShaderQOpenGLShaderProgramQOpenGLTextureQOpenGLTextureBlitterQOpenGLVersionProfileQOpenGLVertexArrayObjectQOpenGLWindowr7   r   r   test_opengl_importsr      s     ***+++$000#///$000)555/;;;,888***%111+++&222&222)555*****r   )__doc__r)   pytestqtpyr   r   r   r   r   r   r	   qtpy.tests.utilsr
   r   r$   r0   r8   rA   markskipif
startswithrO   platformversion_infor   r   r   r7   r   r   <module>r      s     



                   - , , , , ,
 
 
    "* * *      	,%l%e,,&   
M M 
M LH?!1"1"!5!?/   4> 4>	 4>n 		G&   2 2	 2<+ + + + +r   