Add Dock test and remove outdated comments (#659)

* Add test for Dock closable arg

* Remove outdated and debug comments

* Add test for hideTitle dock
This commit is contained in:
Billy SU 2019-06-28 12:51:54 +08:00 committed by Ogi Moore
parent f4be4efdaa
commit 23b4e174f0
2 changed files with 12 additions and 18 deletions

View File

@ -89,28 +89,16 @@ class Dock(QtGui.QWidget, DockDrop):
The actual size will be determined by comparing this Dock's The actual size will be determined by comparing this Dock's
stretch value to the rest of the docks it shares space with. stretch value to the rest of the docks it shares space with.
""" """
#print "setStretch", self, x, y
#self._stretch = (x, y)
if x is None: if x is None:
x = 0 x = 0
if y is None: if y is None:
y = 0 y = 0
#policy = self.sizePolicy()
#policy.setHorizontalStretch(x)
#policy.setVerticalStretch(y)
#self.setSizePolicy(policy)
self._stretch = (x, y) self._stretch = (x, y)
self.sigStretchChanged.emit() self.sigStretchChanged.emit()
#print "setStretch", self, x, y, self.stretch()
def stretch(self): def stretch(self):
#policy = self.sizePolicy()
#return policy.horizontalStretch(), policy.verticalStretch()
return self._stretch return self._stretch
#def stretch(self):
#return self._stretch
def hideTitleBar(self): def hideTitleBar(self):
""" """
Hide the title bar for this Dock. Hide the title bar for this Dock.
@ -150,7 +138,6 @@ class Dock(QtGui.QWidget, DockDrop):
By default ('auto'), the orientation is determined By default ('auto'), the orientation is determined
based on the aspect ratio of the Dock. based on the aspect ratio of the Dock.
""" """
#print self.name(), "setOrientation", o, force
if o == 'auto' and self.autoOrient: if o == 'auto' and self.autoOrient:
if self.container().type() == 'tab': if self.container().type() == 'tab':
o = 'horizontal' o = 'horizontal'
@ -165,19 +152,16 @@ class Dock(QtGui.QWidget, DockDrop):
def updateStyle(self): def updateStyle(self):
## updates orientation and appearance of title bar ## updates orientation and appearance of title bar
#print self.name(), "update style:", self.orientation, self.moveLabel, self.label.isVisible()
if self.labelHidden: if self.labelHidden:
self.widgetArea.setStyleSheet(self.nStyle) self.widgetArea.setStyleSheet(self.nStyle)
elif self.orientation == 'vertical': elif self.orientation == 'vertical':
self.label.setOrientation('vertical') self.label.setOrientation('vertical')
if self.moveLabel: if self.moveLabel:
#print self.name(), "reclaim label"
self.topLayout.addWidget(self.label, 1, 0) self.topLayout.addWidget(self.label, 1, 0)
self.widgetArea.setStyleSheet(self.vStyle) self.widgetArea.setStyleSheet(self.vStyle)
else: else:
self.label.setOrientation('horizontal') self.label.setOrientation('horizontal')
if self.moveLabel: if self.moveLabel:
#print self.name(), "reclaim label"
self.topLayout.addWidget(self.label, 0, 1) self.topLayout.addWidget(self.label, 0, 1)
self.widgetArea.setStyleSheet(self.hStyle) self.widgetArea.setStyleSheet(self.hStyle)
@ -203,7 +187,6 @@ class Dock(QtGui.QWidget, DockDrop):
def startDrag(self): def startDrag(self):
self.drag = QtGui.QDrag(self) self.drag = QtGui.QDrag(self)
mime = QtCore.QMimeData() mime = QtCore.QMimeData()
#mime.setPlainText("asd")
self.drag.setMimeData(mime) self.drag.setMimeData(mime)
self.widgetArea.setStyleSheet(self.dragStyle) self.widgetArea.setStyleSheet(self.dragStyle)
self.update() self.update()
@ -220,7 +203,6 @@ class Dock(QtGui.QWidget, DockDrop):
if self._container is not None: if self._container is not None:
# ask old container to close itself if it is no longer needed # ask old container to close itself if it is no longer needed
self._container.apoptose() self._container.apoptose()
#print self.name(), "container changed"
self._container = c self._container = c
if c is None: if c is None:
self.area = None self.area = None

View File

@ -14,3 +14,15 @@ def test_dock():
assert dock.name() == name assert dock.name() == name
# no surprises in return type. # no surprises in return type.
assert type(dock.name()) == type(name) assert type(dock.name()) == type(name)
def test_closable_dock():
name = "Test close dock"
dock = da.Dock(name=name, closable=True)
assert dock.label.closeButton != None
def test_hide_title_dock():
name = "Test hide title dock"
dock = da.Dock(name=name, hideTitle=True)
assert dock.labelHidden == True