Example #1
0
def connectAppShutdownSignal(handler):
  ''' 
  Qt specific.
  
  Two candidate signals:
  - aboutToQuit()    Event loop finished: may come from system-wide shutdown
  - lastWindowClose()  User closed last window.
  
  GTK: gtk.quit_add(1, self.fileHandler.write) 
  Note this is not quite a signal in GTK, but a special case?
  '''
  getAppInstance().aboutToQuit.connect(handler)
 def getChangeMethod(self):
     ''' 
     Return a function object (callable) of the SUT that creates self's real event.
     
     Called by the replayer (reading from the DRIVING usecase.)
     Replayer then calls the changeMethod, which creates the event.
     Then an eventFilter intercepts the event and stores a copy in the RESULT usecase.
     (To be diffed with the DRIVING usecase.)
     Then SUT handles the event.
     
     In Qt, QCoreApplication.postEvent ( QObject * receiver, QEvent * event )
     
     NOT the widget's method that handles event. 
     In Qt, by convention, the handler has the same name as the event, except for capitalization.
     result = eval( "self.widget." + self.signalName)
     '''
     # During development, was a  problem with getSelf(postEvent)
     app = getAppInstance()
     result = app.postEvent
     
     """
     '''
     Alternative:
     Call the handler directly, bypassing event loop and eventFilter.
     Unfortunately, the standard usecase recording then fails, since it comes from the eventFilter.
     So we need to write to the usecase outside normal.
     '''
     result = eval( "self.widget." + self.signalName)
     """
     
     # print "getChangeMethod returns:", result
     return result