def keyClicks(self, widget, sequence, modifier=qt.Qt.NoModifier, delay=-1): """Simulate clicking a sequence of keys. See QTest.keyClick for details. """ QTest.keyClicks(widget, sequence, modifier, delay) self.qWait(20)
def _fill_order_part(self, description): app = self.app # Part's description QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_0) # modifier, delay app.processEvents() QTest.keyClicks(app.focusWidget(), description) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Part's quantity QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_9) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # deadline, skip it QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Tab) # modifier, delay app.processEvents() # Unit price QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents()
def test_campusLinkLastYears(self): self.ui.tabWid.setCurrentIndex(2) gear = tests.mkGear('J', 10) tests.enterGearInfo(self, gear) QTest.mouseClick(self.tGear.updtBut, QtCore.Qt.LeftButton) self.ui.tabWid.setCurrentIndex(1) self.tMemb.nameSearch.clear() memb = tests.mkMember('A', 1, forms=True, campusLink=True, formsDate=Util.convert_date('Qt2DB', QtCore.QDate.currentDate().addDays(1)), campusDate=Util.convert_date('Qt2DB', QtCore.QDate.currentDate().addDays(-10))) QTest.keyClicks(self.tMemb.nameSearch, memb['FirstName'] + ' ' + memb['LastName']) tests.enterMemberInfo(self, memb) self.assertTrue(self.tMemb.Button_addUpdButClick()) self.ui.tabWid.setCurrentIndex(0) setTransGear(self, gear, 'Name') setTransMemb(self, memb) QTest.mouseClick(self.tTran.payBut, QtCore.Qt.LeftButton) QTest.mouseClick(self.tTran.payWind.payBut, QtCore.Qt.LeftButton) self.tTran.payWind.close() self.tTran.radioOut.click() self.assertTrue(self.tTran.trans())
def _fill_order_part(self, description): app = self.app QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_0) # modifier, delay app.processEvents() QTest.keyClicks(app.focusWidget(), description) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_9) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # deadline QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Tab) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents()
def test_add_task_with_description(self): itemsBefore = self.form.listWidget.count() '''ensures AddTaskEdit contains text''' QTest.keyClicks(self.form.AddTaskEdit, "task one") addButton = self.form.AddTaskButton QTest.mouseClick(addButton, Qt.LeftButton) '''assert there is one more item''' self.assertEqual(self.form.listWidget.count(), itemsBefore+1)
def test_add_task_without_description(self): itemsBefore = self.form.listWidget.count() '''ensures AddTaskEdit is empty''' QTest.keyClicks(self.form.AddTaskEdit, "") addButton = self.form.AddTaskButton QTest.mouseClick(addButton, Qt.LeftButton) '''assert no items were added''' self.assertEqual(self.form.listWidget.count(), itemsBefore)
def _make_basic_preorder(self): app = self.app widget = self.widget mw = self.mw widget.edit_new_order(self.customer.customer_id) widget.customer_order_name.setText(u"AKZO123"+ chr(233)) QTest.keyEvent(QTest.Click, widget.controller_part.view, Qt.Key_Down) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay app.processEvents() QTest.keyClicks(app.focusWidget(), "Order part one") # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Uacute) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_0) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() app.processEvents() # deadline QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Tab) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_S, Qt.ControlModifier ) # modifier, delay app.processEvents() self._encode_imputable_operation() # Leave auto edit to give focus back to parent QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() app.processEvents()
def setTransGear(this, gearAttr, nameID): if nameID == 'Name': IDName = 'ID' else: IDName = 'Name' this.tTran.gNameIDSearch.clear() QTest.keyClicks(this.tTran.gNameIDSearch, gearAttr[nameID]) if this.tTran.gDissAmbSearch.count() > 1: this.tTran.gDissAmbSearch.setCurrentIndex(this.tTran.gDissAmbSearch.findText(gearAttr[IDName]))
def _scan(self,barcode): """ Simulate a real barcode scan. """ bc = str(barcode) + str(BarCode(barcode)._checksum()) mainlog.debug("Sending a scan : {}".format(bc)) QTest.keyClicks(self.app.focusWidget(), bc) # modifier, delay self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Enter) # modifier, delay self.app.processEvents()
def testConfigureDialog(self): if self.pixmap_unavailable: return from mapclientplugins.pointcloudserializerstep.widgets.configuredialog import ConfigureDialog, ConfigureDialogState state = ConfigureDialogState() d = ConfigureDialog(state) self.assertEqual(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(), False) QTest.keyClicks(d._ui.identifierLineEdit, 'hello') self.assertEqual(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(), True) # QTest.mouseClick(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok), QtCore.Qt.LeftButton) newstate = d.getState() self.assertEqual(newstate.identifier(), 'hello')
def test_add_two_tasks_correct_size(self): itemsBefore = self.form.listWidget.count() currentHeight = self.form.listWidget.parentWidget().size().height() '''ensures AddTaskEdit contains text''' QTest.keyClicks(self.form.AddTaskEdit, "task one") addButton = self.form.AddTaskButton QTest.mouseClick(addButton, Qt.LeftButton) QTest.mouseClick(addButton, Qt.LeftButton) '''assert there is two more items, and size grew''' self.assertEqual(self.form.listWidget.count(), itemsBefore+2) newHeight = self.form.listWidget.parentWidget().size().height() twoLines = 2*21 twoSpaces = 2*2 self.assertEqual(currentHeight+twoLines+twoSpaces, newHeight)
def _encode_not_imputable_operation(self): widget = self.widget app = self.app widget.controller_operation.view.setFocus(Qt.OtherFocusReason) QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Down) # modifier, delay # Operation defintion QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_M) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_A) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Operation's description QTest.keyClicks(app.focusWidget(), "Not imputable task") # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Uacute) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Value/price QTest.keyClicks(app.focusWidget(), "123.66") # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Number of hours (skipped because TO is not a fixed price) # Leave auto edit to give focus back to parent QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() app.processEvents()
def testConfigureDialog(self): if self.pixmap_unavailable: return from mapclientplugins.pointcloudserializerstep.widgets.configuredialog import ConfigureDialog, ConfigureDialogState state = ConfigureDialogState() d = ConfigureDialog(state) self.assertEqual( d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(), False) QTest.keyClicks(d._ui.identifierLineEdit, 'hello') self.assertEqual( d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(), True) # QTest.mouseClick(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok), QtCore.Qt.LeftButton) newstate = d.getState() self.assertEqual(newstate.identifier(), 'hello')
def test_pbox(self): """ Method to test if a pbox can be displayed properly. """ # Create the box self.mypbox = Pbox(self.mypyramiddesc) self.mypbox._boxes["c2"].active = False self.mypbox._boxes["c7"].active = False getattr(self.mypbox._boxes["c7"].inputs, "inp").optional = True # Test view pview = PipelineView(self.mypbox) pview.show() # Start the qt loop self.app.exec_() # Test events pview.zoom_in() pview.zoom_out() QTest.keyClicks(pview, "p")
def _fill_order_part(self, description): """ Fill an order part line and be ready to edit the next one. """ mainlog.debug("_fill_order_part : {}".format(description)) app = self.app QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_0) # modifier, delay app.processEvents() QTest.keyClicks(app.focusWidget(), description) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Qantity QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_9) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # skip deadline QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Tab) # modifier, delay app.processEvents() # Price QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_1) # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() mainlog.debug("_fill_order_part : DONE with {}".format(description))
def enterGearInfo(this, gearAttr): this.tGear.clear_fields() this.tGear.gNameIDSearch.clear() QTest.keyClicks(this.tGear.GNameEdit, gearAttr['Name']) QTest.keyClicks(this.tGear.GIDEdit, gearAttr['ID']) this.tGear.QuantSpin.setValue(gearAttr['Quantity']) QTest.keyClicks(this.tGear.PriceEdit, '{:0.2f}'.format(gearAttr['Price'])) this.tGear.PurchDateEdit.setDate( Util.convert_date('DB2Qt', gearAttr['PurchaseDate'])) this.tGear.unitBox.setCurrentIndex(this.tGear.unitBox.findText('kg')) QTest.keyClicks(this.tGear.WeightEdit, str(gearAttr['Weight'])) if gearAttr['ExpirationDate']: this.tGear.ExpDateCkbx.setChecked(True) this.tGear.ExpDateEdit.setDate( Util.convert_date('DB2Qt', gearAttr['ExpirationDate'])) else: this.tGear.ExpDateCkbx.setChecked(False) QTest.keyClicks(this.tGear.ManufacEdit, gearAttr['Manufacturer']) this.tGear.checkoutable.setChecked(gearAttr['Unrentable']) QTest.keyClicks(this.tGear.checkoutable_lineedit, gearAttr['UnrentableReason']) # Certifications for cert in Util.certifications: this.tGear.__dict__[cert + 'CertCkbx'].setChecked(gearAttr[cert + 'Cert']) this.tGear.MaintenanceEdit.setPlainText(gearAttr['CareMaintenance']) this.tGear.NoteEdit.setPlainText(gearAttr['Misc'])
def test_save_preserve_operation_order2(self): order = self._make_order() order_id = order.order_id for i in range(10): operation = self._operation_dao.make() operation.production_file = order.parts[0].production_file[0] operation.description = "," + str(i + 1) operation.operation_model = self.opdef_op operation.planned_hours = (i + 10) * 10 operation.position = 11 - i session().add(operation) self._order_dao.recompute_position_labels(order) session().commit() descriptions = [op.description for op in order.parts[0].operations] mainlog.debug(order) self.widget._panel_visible = True self.widget.reset_order(order_id, overwrite=True) # Edit superficially self.widget.controller_operation.view.setFocus(Qt.OtherFocusReason) for i in range(5): QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Down) # modifier, delay self.app.processEvents() # set on description QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Right) # modifier, delay self.app.processEvents() # change the description QTest.keyClicks(self.app.focusWidget(), "Zulu") self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Enter) # modifier, delay self.app.processEvents() # Another one QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Escape) # stop current editing self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Tab, Qt.ShiftModifier) self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Tab, Qt.ShiftModifier) self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Down) # modifier, delay self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Down) # modifier, delay self.app.processEvents() QTest.keyClicks(self.app.focusWidget(), "Zulu") self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Enter) # modifier, delay self.app.processEvents() # Save QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_S, Qt.ControlModifier) # modifier, delay self.app.processEvents() mainlog.debug(descriptions) mainlog.debug([op.description for op in order.parts[0].operations]) order = dao.order_dao.find_by_id(order_id) operations = order.parts[0].operations for i in range(1, len(descriptions)): # Skip the first one self.assertEqual(descriptions[i].split(',')[1], operations[i].description.split(',')[1])
def setTransMemb(this, membAttr): this.tTran.nameSearch.clear() QTest.keyClicks(this.tTran.nameSearch, membAttr['FirstName'] + ' ' + membAttr['LastName']) if this.tTran.bDayBox.count() > 1: this.tTran.bDayBox.setCurrentIndex(this.tTran.bDayBox.findText(membAttr['Birthday']))
def enterMemberInfo(this, memberAttr): this.tMemb.clear_fields() # this.tMemb.nameSearch.clear() QTest.keyClicks(this.tMemb.MFNameEdit, memberAttr['FirstName']) QTest.keyClicks(this.tMemb.MLNameEdit, memberAttr['LastName']) QTest.keyClicks(this.tMemb.PhoneEdit, memberAttr['Phone']) QTest.keyClicks(this.tMemb.EmailEdit, memberAttr['Email']) QTest.keyClicks(this.tMemb.MNumEdit, memberAttr['StudentID']) this.tMemb.FormsCkbx.setChecked(memberAttr['FormsCurrent']) this.tMemb.campLinkCkbx.setChecked(memberAttr['CampusLink']) this.tMemb.FormsDateEdit.setDate( Util.convert_date('DB2Qt', memberAttr['FormsDate'])) this.tMemb.campLinkDateEdit.setDate( Util.convert_date('DB2Qt', memberAttr['CampusLinkDate'])) this.tMemb.BirthdayEdit.setDate( Util.convert_date('DB2Qt', memberAttr['Birthday'])) this.tMemb.statusBox.setCurrentIndex( this.tMemb.statusBox.findText(memberAttr['MembStat'])) this.tMemb.studStatBox.setCurrentIndex( this.tMemb.studStatBox.findText(memberAttr['StudStat'])) QTest.keyClicks(this.tMemb.streetEdit, memberAttr['street']) QTest.keyClicks(this.tMemb.cityEdit, memberAttr['city']) this.tMemb.stateBox.setCurrentIndex( this.tMemb.stateBox.findText(memberAttr['state'])) QTest.keyClicks(this.tMemb.zipEdit, memberAttr['zip']) # Emergency Contact 1 Info QTest.keyClicks(this.tMemb.emNameEdit, memberAttr['EmName']) QTest.keyClicks(this.tMemb.emRelaltEdit, memberAttr['EmRel']) QTest.keyClicks(this.tMemb.emHPhoneEdit, memberAttr['EmPhoneH']) QTest.keyClicks(this.tMemb.emWPhoneEdit, memberAttr['EmPhoneW']) QTest.keyClicks(this.tMemb.emCPhoneEdit, memberAttr['EmPhoneC']) # QTest.keyClicks(this.tMemb.emStreetEdit, memberAttr['EmStreet']) # QTest.keyClicks(this.tMemb.emCityEdit , memberAttr['EmCity' ]) # this.tMemb.emStateBox.setCurrentIndex(this.tMemb.emStateBox.findText(memberAttr['EmState' ])) # QTest.keyClicks(this.tMemb.emZipEdit , memberAttr['EmZip' ]) # Room mate name and phone QTest.keyClicks(this.tMemb.rommateEdit, memberAttr['RoommateName']) QTest.keyClicks(this.tMemb.rommatePhoneEdit, memberAttr['RoommatePhone']) # Insurance fields QTest.keyClicks(this.tMemb.insEdit, memberAttr['InsurName']) QTest.keyClicks(this.tMemb.insPolEdit, memberAttr['InsurPol']) QTest.keyClicks(this.tMemb.insGrpEdit, memberAttr['InsurGrp']) # Certifications for cert in Util.certifications: this.tMemb.__dict__[cert + 'CertCkbx'].setChecked(memberAttr[cert + 'Cert']) if this.tMemb.__dict__[cert + 'CertCkbx'].isChecked(): this.tMemb.__dict__[cert + 'DateEdit'].setDate( memberAttr[cert + 'CertDate']) this.tMemb.__dict__[cert + 'Vouched'].setText(memberAttr[cert + 'CertVouch']) # Medical Condition this.tMemb.medEdit.setPlainText(memberAttr['Med']) # Member Notes this.tMemb.noteEdit.setPlainText(memberAttr['Note'])
def test_copy_paste_operations_to_new_part(self): order = self._make_order() order_part = order.parts[0] order_part.notes = "A note" pf = order_part.production_file[0] operation = self._operation_dao.make() operation.position = 1 operation.production_file = pf operation.description = "Alpha" operation.operation_model = self.opdef_op operation.planned_hours = 1 session().add(operation) operation = self._operation_dao.make() operation.position = 2 operation.production_file = pf operation.description = "Beta" operation.operation_model = self.opdef_op operation.planned_hours = 2 session().add(operation) session().commit() self.edit_order_widget.reset_order(order.order_id, overwrite=True) self.edit_order_widget.refresh_action( ) # The panel is outside the panel manager => I force the refresh # Copy the operations of this order part self.edit_order_widget.controller_operation.view.setFocus( Qt.OtherFocusReason) QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_A, Qt.ControlModifier) # modifier, delay self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_C, Qt.ControlModifier) # modifier, delay self.app.processEvents() # Add a new order part self.edit_order_widget.controller_part.view.setFocus( Qt.OtherFocusReason) QTest.keyEvent(QTest.Click, self.edit_order_widget.controller_part.view, Qt.Key_F5, Qt.ShiftModifier) # modifier, delay self.app.processEvents() QTest.keyClicks(self.app.focusWidget(), "O") # Start edit self.app.processEvents() QTest.keyClicks(self.app.focusWidget(), "rder part tWO") # complete edit self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Enter) # modifier, delay self.app.processEvents() # quantity QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_1) # modifier, delay self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Enter) # modifier, delay self.app.processEvents() # skip deadline QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_Tab) # modifier, delay self.app.processEvents() # Price QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_1) # modifier, delay self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_1) # modifier, delay self.app.processEvents() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_1) # modifier, delay self.app.processEvents() # Now paste operations self.edit_order_widget.controller_operation.view.setFocus( Qt.OtherFocusReason) # self.app.exec_() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_V, Qt.ControlModifier) # modifier, delay self.app.processEvents() #self.app.exec_() QTest.keyEvent(QTest.Click, self.app.focusWidget(), Qt.Key_S, Qt.ControlModifier) # modifier, delay self.app.processEvents() order = session().query(Order).filter( Order.order_id == order.order_id).one() for op in order.parts[1].operations: mainlog.debug(op) # self.app.exec_() assert "desc" in order.parts[1].operations[0].description
def _encode_imputable_operation(self): widget = self.widget app = self.app widget.controller_operation.view.setFocus(Qt.OtherFocusReason) QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Down) # modifier, delay app.processEvents() # Operation defintion QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_T) # modifier, delay app.processEvents() ed = app.focusWidget() for i in range(10000): app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_O) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_O) # modifier, delay app.processEvents() ed = app.focusWidget() app.processEvents() app.processEvents() ed.hide() ed.close() ed.repaint() app.processEvents() app.processEvents() # app.exec_() for i in range(10000): app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() for i in range(10000): app.processEvents() # Operation's description QTest.keyClicks(app.focusWidget(), "Description op 1, TOurnage") # modifier, delay QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Uacute) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Valude/price (skipped because TO is not a fixed price) # Number of hours QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_8) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Leave auto edit to give focus back to parent QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() app.processEvents()
def _encode_imputable_operation(self, description="Description op 1, TOurnage", pause=False): widget = self.widget app = self.app widget.controller_operation.view.setFocus(Qt.OtherFocusReason) mainlog.debug("*** Activating operation selection") QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Down) # modifier, delay app.processEvents() # Operation defintion QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_T) # modifier, delay app.processEvents() ed = app.focusWidget() for i in range(10000): app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_O) # modifier, delay app.processEvents() if pause: app.exec_() mainlog.debug("*** Selecting operation selection") for i in range(10000): app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() for i in range(10000): app.processEvents() mainlog.debug("*** Entering description") mainlog.debug(app.focusWidget()) # Operation's description QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_8) # modifier, delay app.processEvents() print(app.focusWidget()) QTest.keyClicks(app.focusWidget(), description) # modifier, delay print(app.focusWidget()) QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Uacute) # modifier, delay app.processEvents() mainlog.debug("*** hitting enter") QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() mainlog.debug(app.focusWidget()) mainlog.debug("*** entering number of hours") # Value/price (skipped because TO is not a fixed price) # Number of hours QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_8) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Enter) # modifier, delay app.processEvents() # Leave auto edit to give focus back to parent QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_Escape) # modifier, delay app.processEvents() app.processEvents()