
    eS                        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$                  j'                  exr  ej(                  d
      d      d        Zej$                  j'                  ej,                  dk(  xr ej.                  dd dk(  d      d        Zej$                  j'                  exs e d      d        Zd Zy)zTest QtGui.    N)PYQT5PYQT_VERSIONPYSIDE2PYSIDE6QtCoreQtGui	QtWidgets)not_using_condac                 x   t         j                  j                  J t         j                  j                  J t        j                  dd      }t        j                  |      }t        j                  |      }|j                  d      }|j                  d      }|t        dd      v sJ d|cxk  rdk  sJ  J y)	z)Test QFontMetrics and QFontMetricsF widthNtimes   Test(   >   '   ?   )r   QFontMetricswidthQFontMetricsFQFontrange)qtbotfontfont_metricsfont_metricsFr   widthFs         7/usr/lib/python3/dist-packages/qtpy/tests/test_qtgui.pytest_qfontmetrics_widthr      s    ##///$$000;;w#D%%d+L''-Mv&E  (FE"bM!!!2    c                     t         j                  j                  J t        j                  d      }|j                          y)z'Test functions mapping for QtGui.QDrag.N)r   QDragexec_)r   drags     r   test_qdrag_functionsr$       s/    ;;(((;;tDJJLr   c                     t         j                  j                  J t         j                  j                         xs) t        j                  t        j
                  t        g      } | J t        j                  j                  dt         j                  j                         j                         t         j                  j                          t         j                  j                         xs) t        j                  t        j
                  t        g      } | J t        j                  j                  dt         j                  j                         j                         | j                          y)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	"/C ??
MMS%"7"7"@"@"B"G"GH	!



(
(
* e.C.C	"/C ??
MMS%"7"7"@"@"B"G"GHIIKr   c                      t         j                  J t         j                  J t         j                  J t         j                  J t         j
                  J y)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   sX    ==$$$)))!!---??&&&)))r   c                     t         j                  j                  J t        j                  d      }| \  }}|j                  |       |j                         sJ y)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   sT    %%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 y)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044444;;##u{{'A'A'N'NNNN;;!1!1!8!8888<<&&%,,*=*=*L*LLLLr   darwin   )      z"Stalls on macOS CI with Python 3.7c                 b    G d dt         j                        } |       }|j                  dd       |j                          | j	                  |      5  | j                  |t        j                  dd             | j                  |t        j                  j                         ddd       dD ]%  }d	D ]  }t        t        t        |      |      rJ  ' d
D ]  }t        t        j                  |      rJ  dD ]%  }dD ]  }t        t        t        |      |      rJ  ' y# 1 sw Y   xY w)z
    Test `QMouseEvent.pos` and related functions removed in Qt 6,
    and `QMouseEvent.position`, etc., missing from Qt 5.
    c                   0    e Zd Zdej                  ddfdZy)2test_QSomethingEvent_pos_functions.<locals>.WindoweventreturnNc                 6   |j                         |j                         z
  | j                  t        j                  dd            k(  sJ |j                         j                         |j                         k(  sJ |j                         j                         |j                         k(  sJ |j                         j                         |j                         k(  sJ |j                         j                         |j                         k(  sJ |j                         j                         |j                         j                         k(  sJ |j                         j                         |j                         j                         k(  sJ |j                         j                         |j                         j                         k(  sJ |j                         j                         |j                         j                         k(  sJ |j                          y )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    99;==?eggi///99;==?eggi///??$&&(EMMO;;;??$&&(EMMO;;;>>#%%'599;==?:::>>#%%'599;==?:::'')++-1B1D1D1FFFF'')++-1B1D1D1FFFFLLNr   )__name__
__module____qualname__r   QMouseEventrf   r7   r   r   WindowrV   a   s    	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'   &&   XF
#s#
KKM			6	" 8b% 89&&))"6"678 I >	
 
	>I 75&19===
	>> 3 5	u(()4445 F >4 	>I75&19===	>>18 8s   AD%%D.zPySide{2,6} specific testc                     t        j                  d      } t        j                  |       }|j                  t         j                  j                        rJ |j                  t         j                  j
                  t         j                  j                        sJ |j                         dk(  sJ |j                  t         j                  j                        sJ |j                  t         j                  j                  dt         j                  j                        sJ |j                         dk(  sJ |j                  t         j                  j                        sJ |j                         |j                         k(  sJ |j                  t         j                  j                  t         j                  j                  d      sJ |j                         dk(  sJ y)	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#4#:#:;;;##))      E)))u0066777##
))    
  J...u0066777??///""$$	  
  M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 y)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 LLH?!1!1"1!5!?/  4>	4>n 		G&  2	2<+r   