示例#1
0
    def test_mouse_drag(self):
        """Test setting extents by dragging works.

        This currently fails as QTest does not properly do the mouse
        interactions with the canvas.

        """

        # Click the capture button
        QTest.mouseClick(self.dialog.capture_button, Qt.LeftButton)

        # drag a rect on the canvas
        QTest.mousePress(CANVAS, Qt.LeftButton, pos=QPoint(0, 0), delay=500)
        QTest.mouseRelease(CANVAS,
                           Qt.LeftButton,
                           pos=QPoint(300, 300),
                           delay=-1)

        # on drag the extents selector windows should appear again
        QTest.qWaitForWindowShown(self.dialog)
        # Click ok to dispose of the window again
        ok = self.dialog.button_box.button(QtGui.QDialogButtonBox.Ok)
        QTest.mouseClick(ok, Qt.LeftButton)

        # Check the extent emitted on closing teh dialog is correct
        expected_extent = QgsRectangle(10.0, 10.0, 30.0, 20.0)
        self.assertEqual(self.extent.toString(), expected_extent.toString())
    def test_mouse_drag(self):
        """Test setting extents by dragging works.

        This currently fails as QTest does not properly do the mouse
        interactions with the canvas.

        """
        # Imported here because it is not available in OSX QGIS bundle
        # pylint: disable=redefined-outer-name
        from PyQt4.QtTest import QTest

        # Click the capture button
        QTest.mouseClick(self.dialog.capture_button, Qt.LeftButton)

        # drag a rect on the canvas
        QTest.mousePress(CANVAS, Qt.LeftButton, pos=QPoint(0, 0), delay=500)
        QTest.mouseRelease(
            CANVAS, Qt.LeftButton,
            pos=QPoint(300, 300),
            delay=-1)

        # on drag the extents selector windows should appear again
        QTest.qWaitForWindowShown(self.dialog)
        # Click ok to dispose of the window again
        ok = self.dialog.button_box.button(QtGui.QDialogButtonBox.Ok)
        QTest.mouseClick(ok, Qt.LeftButton)

        # Check the extent emitted on closing teh dialog is correct
        expected_extent = QgsRectangle(10.0, 10.0, 30.0, 20.0)
        self.assertEqual(self.extent.toString(), expected_extent.toString())
示例#3
0
    def add_one_pick(self):
        '''Add a single pick to pile_viewer'''
        pv = self.pile_viewer
        QTest.mouseDClick(pv.viewer, Qt.LeftButton)

        # This should be done also by mouseDClick().
        QTest.mouseRelease(pv.viewer, Qt.LeftButton)
        QTest.mouseClick(pv.viewer, Qt.LeftButton)
示例#4
0
 def scrollAreaInteract(cls, area):
 #        print "scrollAreaInteract", area
     from PyQt4.QtTest import QTest
     geom = area.geometry()
     randpos = lambda: geom.topLeft() + QtCore.QPoint(geom.width() * random.random(), geom.height() * random.random())
     QTest.mouseMove(area, randpos(), 2)
     QTest.mouseClick(area, Qt.LeftButton, pos=randpos(), delay=2)
     QTest.mouseDClick(area, Qt.LeftButton, pos=randpos(), delay=2)
     QTest.mousePress(area, Qt.LeftButton, pos=randpos(), delay=2)
     QTest.mouseRelease(area, Qt.LeftButton, pos=randpos(), delay=2)
示例#5
0
 def drag_slider(self, slider):
     ''' Click *slider*, drag from one side to the other, release mouse
     button repeat to restore inital state'''
     position = self.get_slider_position(slider)
     QTest.mouseMove(slider, pos=position.topLeft())
     QTest.mousePress(slider, Qt.LeftButton)
     QTest.mouseMove(slider, pos=position.bottomRight())
     QTest.mouseRelease(slider, Qt.LeftButton)
     QTest.mousePress(slider, Qt.LeftButton)
     QTest.mouseMove(slider, pos=position.topLeft())
     QTest.mouseRelease(slider, Qt.LeftButton)
示例#6
0
    def test_custom_data_drop(self):
        self.widget = DragAndDropWidget()

        index = self.widget.drag.model.index(1, 0)
        pos = self.widget.drag.visualRect(index).center()
        pos = self.widget.drag.mapFromGlobal(pos)
        self.widget.drag.setCurrentIndex(index)

        QTest.mousePress(self.widget.drag,
                         QtCore.Qt.LeftButton,
                         pos=pos,
                         delay=1)
        QTest.mouseMove(self.widget.drop)
        QTest.mouseRelease(self.widget.drop, QtCore.Qt.LeftButton)

        self.pause(2)
示例#7
0
 def remove_layer(self, layer):
     """ Remove a layer via the widget remove button """
     widget_item = self.widget[layer]
     self.widget.layerTree.setCurrentItem(widget_item)
     QTest.mousePress(self.widget.layerRemoveButton, Qt.LeftButton)
     QTest.mouseRelease(self.widget.layerRemoveButton, Qt.LeftButton)
示例#8
0
 def test_eventFilter_mouseRelease(self):
     """Test when the mouse button is released inside the icon.
     """
     self.icon_label.mouse_release_icon.connect(self.assert_icon_emitted)
     QTest.mouseRelease(self.icon_label, QtCore.Qt.LeftButton)
示例#9
0
文件: FsmState.py 项目: cfavi/fsmed
        if change == QtGui.QGraphicsItem.ItemPositionHasChanged:
            for x in self.inboundTransitions + self.outboundTransitions:
                x.updatePosition()
        
        return super(FsmState, self).itemChange(change,value)

    # def mouseDoubleClickEvent(self, event):        
    #     pass
if __name__ == '__main__':
    import sys
    from MainWindow import MainWindow
    from PyQt4.QtTest import QTest
    from PyQt4.QtCore import Qt
    
    app = QtGui.QApplication(sys.argv)


    mainWindow = MainWindow()
    mainWindow.setGeometry(100, 100, 800, 500)
    mainWindow.show()

    QTest.mouseClick(mainWindow.addStateButton, Qt.LeftButton)
    QTest.mouseClick(mainWindow.view.viewport(), Qt.LeftButton, Qt.NoModifier, QtCore.QPoint(400,200))
    QTest.mouseClick(mainWindow.view.viewport(), Qt.LeftButton, Qt.NoModifier, QtCore.QPoint(100,250))
    QTest.mouseClick(mainWindow.addTransitionButton, Qt.LeftButton)
    QTest.mousePress(mainWindow.view.viewport(), Qt.LeftButton, Qt.NoModifier, QtCore.QPoint(400,200))
    QTest.mouseMove(mainWindow.view.viewport(), QtCore.QPoint(100,250))
    QTest.mouseRelease(mainWindow.view.viewport(), Qt.LeftButton, Qt.NoModifier, QtCore.QPoint(100,250))
        
    sys.exit(app.exec_()) 
示例#10
0
文件: FsmScene.py 项目: ongbe/fsmed
            if isinstance(item, type):
                return True
        return False


if __name__ == '__main__':
    import sys
    from MainWindow import MainWindow
    from PyQt4.QtTest import QTest
    from PyQt4.QtCore import Qt

    app = QtGui.QApplication(sys.argv)

    mainWindow = MainWindow()
    mainWindow.setGeometry(100, 100, 800, 500)
    mainWindow.show()

    QTest.mouseClick(mainWindow.addStateButton, Qt.LeftButton)
    QTest.mouseClick(mainWindow.view.viewport(), Qt.LeftButton, Qt.NoModifier,
                     QtCore.QPoint(400, 200))
    QTest.mouseClick(mainWindow.view.viewport(), Qt.LeftButton, Qt.NoModifier,
                     QtCore.QPoint(100, 250))
    QTest.mouseClick(mainWindow.linePointerButton, Qt.LeftButton)
    QTest.mousePress(mainWindow.view.viewport(), Qt.LeftButton, Qt.NoModifier,
                     QtCore.QPoint(400, 200))
    QTest.mouseMove(mainWindow.view.viewport(), QtCore.QPoint(100, 250))
    QTest.mouseRelease(mainWindow.view.viewport(), Qt.LeftButton,
                       Qt.NoModifier, QtCore.QPoint(100, 250))

    sys.exit(app.exec_())
示例#11
0
 def test_eventFilter_mouseRelease(self):
     """Test when the mouse button is released inside the icon.
     """
     self.icon_label.mouse_release_icon.connect(self.assert_icon_emitted)
     QTest.mouseRelease(self.icon_label, QtCore.Qt.LeftButton)
示例#12
0
文件: test_ui.py 项目: sixam/dw6824
 def _drawRandomStroke(self):
     numpoints = random.randint(1,20) 
     QTest.mousePress(self.area,QtCore.Qt.LeftButton,pos=self._getPoint(),delay=0)
     for i in range(numpoints):
         QTest.mouseMove(self.area,self._getPoint(),delay=10)
     QTest.mouseRelease(self.area,QtCore.Qt.LeftButton,pos=self._getPoint(),delay=10)