From 5fd18253e19692f30c9f07178cd9846fd0144a09 Mon Sep 17 00:00:00 2001 From: Rebecca Breu Date: Tue, 6 Apr 2021 14:37:48 +0200 Subject: [PATCH] Unit tests --- beeref/selection.py | 10 ++-- tests/assets/test1item.bee | Bin 0 -> 16384 bytes tests/test_items.py | 11 ++++ tests/test_scene.py | 1 + tests/test_view.py | 120 ++++++++++++++++++++++++++++++++++--- 5 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 tests/assets/test1item.bee diff --git a/beeref/selection.py b/beeref/selection.py index 9d58bcc..8d39411 100644 --- a/beeref/selection.py +++ b/beeref/selection.py @@ -34,7 +34,7 @@ SELECT_COLOR = QtGui.QColor(116, 234, 231, 255) def with_anchor(func): - """Decorator that handles anchors for translate operations. + """Decorator that adds an anchor parameter to transform operations. The anchor is given in item coordinates. """ @@ -45,7 +45,7 @@ def with_anchor(func): anchor = anchor if anchor else QtCore.QPointF(0, 0) prev = self.mapToScene(anchor) - func(self, value, anchor) + func(self, value) diff = self.mapToScene(anchor) - prev self.setPos(self.pos() - diff) @@ -55,7 +55,7 @@ def with_anchor(func): class BaseItemMixin: @with_anchor - def setScale(self, value, anchor=None): + def setScale(self, value): if value <= 0: return @@ -72,14 +72,14 @@ class BaseItemMixin: self.setZValue(self.scene().max_z + 0.001) @with_anchor - def setRotation(self, value, anchor): + def setRotation(self, value): logger.debug(f'Setting rotation for {self} to {value}') super().setRotation(value) @property def center_scene_coords(self): """The item's center in scene coordinates.""" - return self.mapToScene(QtCore.QPointF(self.width/2, self.height/2)) + return self.mapToScene(QtCore.QPointF(self.width, self.height) / 2) class SelectableMixin(BaseItemMixin): diff --git a/tests/assets/test1item.bee b/tests/assets/test1item.bee new file mode 100644 index 0000000000000000000000000000000000000000..df0a213f1afe5293d2d8e7ea4ae07ab786363147 GIT binary patch literal 16384 zcmeI&&rj1(902gwP1r`sH%092_(( zaxlg}fTITwT>KaO2Z#r6p7iL!i=H@`;A;o_p~E9l^L^>-Tl@XC`}XsCY18G0S%Xo$ zQL{~*;Td!V2?Dx@F+ym7_e;E=H6Q=cy)E!KcAP)^4=J{F%!v7-gJMG?FGNR&p9vR*zA>I}vQhI-RHAr=YG{qjoF%sFsBuU4-j9VfdB}A00@8p2!H?xfB*=900@8p z2wb!P6)vOEKp+qb27`Nk%V?Oo_3pS;#o0KYFD`xfcK9Q{RWoVaF50vnFY)(AachTd z)vEC#r8eD&ZyGGl_zNN@t~(CpgS#=)n3=Mwo2}=684b%9eSz?QAOHd&00JNY0w4ea zAOHd&00JQJPYLYJ3Bg#%H{)xLi=vo_bv<4Co==O@iI{jZCf>s0?YY_Mx!GCt@x8{caDspV)uAKmLUeA!~8XL1^l_+l9uPdH2KlQASpoTr*An)d!Mo zsxw-~PYkw&)0w6GqrFI!CyiwICl|qk()#-G$;rvH!NHMNpGEOU0DZa}`7S)&KjAqj yLzL9p