Skip to content

Commit

Permalink
tests: Add store/restoreGeometryAndLayoutState tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-erjavec committed Jun 15, 2018
1 parent 8d23609 commit 52fc390
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Orange/widgets/tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# pylint: disable=missing-docstring

from unittest.mock import patch, MagicMock

from AnyQt.QtCore import QRect, QByteArray
from AnyQt.QtGui import QShowEvent
from AnyQt.QtWidgets import QAction

Expand Down Expand Up @@ -187,3 +187,26 @@ def test_old_style_messages(self):

w.Error.clear()
self.assertEqual(len(messages), 0)

def test_store_restore_layout_geom(self):
class Widget(OWWidget):
name = "Who"
want_control_area = True

w = Widget()
splitter = w._OWWidget__splitter # type: OWWidget._Splitter
splitter.setControlAreaVisible(False)
w.setGeometry(QRect(51, 52, 53, 54))
state = w.saveGeometryAndLayoutState()
w1 = Widget()
self.assertTrue(w1.restoreGeometryAndLayoutState(state))
self.assertEqual(w1.geometry(), QRect(51, 52, 53, 54))
self.assertFalse(w1.controlAreaVisible)

Widget.want_control_area = False
w2 = Widget()
self.assertTrue(w2.restoreGeometryAndLayoutState(state))
self.assertEqual(w1.geometry(), QRect(51, 52, 53, 54))

self.assertFalse((w2.restoreGeometryAndLayoutState(QByteArray())))
self.assertFalse(w2.restoreGeometryAndLayoutState(QByteArray(b'ab')))

0 comments on commit 52fc390

Please sign in to comment.