Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions pyqttester.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def parse_args():

parser_record.add_argument(
'--events-include', metavar='REGEX',
default=r'MouseEvent,KeyEvent,CloseEvent', # TODO: add Drag, Focus, Hover ?
default=r'MouseEvent,KeyEvent,CloseEvent,FocusEvent,DragLeaveEvent,DragEnterEvent,HoverEvent,HideEvent,'
'ShowEvent,StatusTipEvent,ResizeEvent,SocketNotifier,StatusTipEvent', # TODO: add Drag, Focus, Hover ?
#ChildEvent do not work'
help='When recording, record only events that match the filter.')
parser_record.add_argument(
'--events-exclude', metavar='REGEX',
Expand Down Expand Up @@ -408,7 +410,15 @@ def _serialize_value(cls, value, attr):
value.y(),
value.width(),
value.height())
# Perhaps it's an enum value from Qt namespace
if isinstance(value, (QtCore.QSize, QtCore.QSizeF)):
return 'QtCore.{}({}, {})'.format(type(value).__name__,
value.width(),
value.height())
#if isinstance(value, (QtGui.QActionEvent)):
# return 'QtGui.{}({}, {}, {})'.format(type(value).__name__,value.parent(), value.type(), value.action(), value.before())

#if isinstance(value, (QtCore.QString)):
# return '{}()'.format(type(value).__name__)
assert isinstance(Qt.LeftButton, int)
if isinstance(value, int):
s = cls._qenum_key(Qt, value)
Expand All @@ -431,6 +441,19 @@ def _serialize_value(cls, value, attr):
'QKeyEvent': 'type key modifiers text isAutoRepeat count'.split(),
'QMoveEvent': 'pos oldPos'.split(),
'QCloseEvent': [],
'QChildEvent' : 'type child'.split(),
'QFocusEvent' : 'type reason'.split(),
'QDragLeaveEvent' : [],
'QDragEnterEvent' : 'point actions data buttons modifiers'.split(),
'QHoverEvent' : 'type pos oldPos'.split(), #for qt4
'QPaintEvent' : 'paintRegion'.split(),
'QHideEvent' : [],
'QShowEvent' : [],
'QStatusTipEvent' : 'tip'.split(),
'QResizeEvent' : 'size oldSize'.split(),
'QSocketNotifier' : 'socket type parent'.split(), #problem with QObject* parent
'QActionEvent' : 'type action before'.split(),
'QStatusTipEvent' : 'tip'.split(),
}

@classmethod
Expand Down Expand Up @@ -646,6 +669,7 @@ class EventRecorder(_EventFilter):
def __init__(self, file, events_include, events_exclude):
super().__init__()
self.file = file
self.spuscen = []

# Prepare the recorded events stack;
# the first entry is the protocol version
Expand All @@ -670,8 +694,10 @@ def eventFilter(self, obj, event):
# Only process out-of-application, system (e.g. X11) events
# if not event.spontaneous():
# return False

is_skipped = (not self.event_matches(type(event).__name__) or
not isinstance(obj, QWidget)) # FIXME: This condition is too strict (QGraphicsItems are QOjects)

log_ = log.debug if is_skipped else log.info
log_('Caught %s%s %s event (%s) on object %s',
'skipped' if is_skipped else 'recorded',
Expand All @@ -692,6 +718,9 @@ def eventFilter(self, obj, event):
serialized = self.resolver.getstate(obj, event)
if serialized:
self.events.append(serialized)
if is_skipped:
self.spuscen.append(EVENT_TYPE.get(event.type(),
'Unknown(type=' + str(event.type()) + ')'))
return False

def close(self):
Expand All @@ -702,6 +731,8 @@ def close(self):
len(self.events) - SCENARIO_FORMAT_VERSION - 1, self.file.name)
log.debug(self.events)

for i in set(self.spuscen):
log.info(i)

class EventReplayer(_EventFilter):
def __init__(self, file):
Expand Down
Empty file modified setup.py
100644 → 100755
Empty file.