コード例 #1
0
    def test_collapse_empty(self):
        """ Test for collapse function when the collapse origin is an empty
        tabwidget. It's sibling can have an arbitrary layout and the result
        would be such that this layout is transferred to the parent.
        """
        # setup
        root = EditorAreaWidget(editor_area=SplitEditorAreaPane(), parent=None)
        tabwidget = root.tabwidget()
        tabwidget.setParent(None)
        left, left_left, left_right = self._setUp_collapse(parent=root)
        right = EditorAreaWidget(editor_area=root.editor_area, parent=root)
        root.leftchild = left
        root.rightchild = right

        # perform collapse on leftchild
        right.collapse()

        # test
        # is the layout of root now same as left?
        self.assertEqual(root.count(), 2)
        self.assertEqual(root.leftchild, left_left)
        self.assertEqual(root.rightchild, left_right)

        # are the contents of left_left and left_right preserved
        self.assertEqual(root.leftchild.tabwidget().count(), 2)
        self.assertEqual(root.rightchild.tabwidget().count(), 2)
        self.assertEqual(root.leftchild.tabwidget().currentIndex(), 1)
        self.assertEqual(root.rightchild.tabwidget().currentIndex(), 0)

        # what is the current active_tabwidget?
        self.assertEqual(root.editor_area.active_tabwidget,
                         root.leftchild.tabwidget())
コード例 #2
0
    def test_collapse_empty(self):
        """ Test for collapse function when the collapse origin is an empty 
        tabwidget. It's sibling can have an arbitrary layout and the result
        would be such that this layout is transferred to the parent.
        """
        # setup
        root = EditorAreaWidget(editor_area=SplitEditorAreaPane(), parent=None)
        tabwidget = root.tabwidget()
        tabwidget.setParent(None)
        left, left_left, left_right = self._setUp_collapse(parent=root)
        right = EditorAreaWidget(editor_area=root.editor_area, parent=root)
        root.leftchild = left
        root.rightchild = right

        # perform collapse on leftchild
        right.collapse()

        # test
        # is the layout of root now same as left?
        self.assertEquals(root.count(), 2)
        self.assertEquals(root.leftchild, left_left)
        self.assertEquals(root.rightchild, left_right)

        # are the contents of left_left and left_right preserved
        self.assertEquals(root.leftchild.tabwidget().count(), 2)
        self.assertEquals(root.rightchild.tabwidget().count(), 2)
        self.assertEquals(root.leftchild.tabwidget().currentIndex(), 1)
        self.assertEquals(root.rightchild.tabwidget().currentIndex(), 0)

        # what is the current active_tabwidget?
        self.assertEquals(root.editor_area.active_tabwidget,
                          root.leftchild.tabwidget())
コード例 #3
0
    def _setUp_split(self, parent=None):
        """ Sets up the root splitter for splitting. Returns this root.

        parent : parent of the returned root
        """
        root = EditorAreaWidget(editor_area=SplitEditorAreaPane(), parent=parent)
        btn0 = QtGui.QPushButton('0')
        btn1 = QtGui.QPushButton('1')
        tabwidget = root.tabwidget()
        tabwidget.addTab(btn0, '0')
        tabwidget.addTab(btn1, '1')
        tabwidget.setCurrentIndex(1)

        return root
コード例 #4
0
    def _setUp_split(self, parent=None):
        """ Sets up the root splitter for splitting. Returns this root.

        parent : parent of the returned root
        """
        root = EditorAreaWidget(editor_area=SplitEditorAreaPane(),
                                parent=parent)
        btn0 = QtGui.QPushButton('0')
        btn1 = QtGui.QPushButton('1')
        tabwidget = root.tabwidget()
        tabwidget.addTab(btn0, '0')
        tabwidget.addTab(btn1, '1')
        tabwidget.setCurrentIndex(1)

        return root
コード例 #5
0
    def _setUp_collapse(self, parent=None):
        """ Creates a root, its leftchild and rightchild, so that collapse can
        be tested on one of the children.

        Returns the root, leftchild and rightchild of such layout.

        parent : parent of the returned root
        """
        # setup leftchild
        left = EditorAreaWidget(editor_area=SplitEditorAreaPane(), parent=None)
        btn0 = QtGui.QPushButton('btn0')
        btn1 = QtGui.QPushButton('btn1')
        tabwidget = left.tabwidget()
        tabwidget.addTab(btn0, '0')
        tabwidget.addTab(btn1, '1')
        tabwidget.setCurrentIndex(1)
        
        # setup rightchild
        right = EditorAreaWidget(editor_area=left.editor_area, parent=None)
        btn2 = QtGui.QPushButton('btn2')
        btn3 = QtGui.QPushButton('btn3')
        tabwidget = right.tabwidget()
        tabwidget.addTab(btn2, '2')
        tabwidget.addTab(btn3, '3')
        tabwidget.setCurrentIndex(0)
        
        # setup root
        root = EditorAreaWidget(editor_area=left.editor_area, parent=parent)
        tabwidget = root.tabwidget()
        tabwidget.setParent(None)
        root.addWidget(left)
        root.addWidget(right)
        root.leftchild = left
        root.rightchild = right

        return root, left, right
コード例 #6
0
    def _setUp_collapse(self, parent=None):
        """ Creates a root, its leftchild and rightchild, so that collapse can
        be tested on one of the children.

        Returns the root, leftchild and rightchild of such layout.

        parent : parent of the returned root
        """
        # setup leftchild
        left = EditorAreaWidget(editor_area=SplitEditorAreaPane(), parent=None)
        btn0 = QtGui.QPushButton('btn0')
        btn1 = QtGui.QPushButton('btn1')
        tabwidget = left.tabwidget()
        tabwidget.addTab(btn0, '0')
        tabwidget.addTab(btn1, '1')
        tabwidget.setCurrentIndex(1)

        # setup rightchild
        right = EditorAreaWidget(editor_area=left.editor_area, parent=None)
        btn2 = QtGui.QPushButton('btn2')
        btn3 = QtGui.QPushButton('btn3')
        tabwidget = right.tabwidget()
        tabwidget.addTab(btn2, '2')
        tabwidget.addTab(btn3, '3')
        tabwidget.setCurrentIndex(0)

        # setup root
        root = EditorAreaWidget(editor_area=left.editor_area, parent=parent)
        tabwidget = root.tabwidget()
        tabwidget.setParent(None)
        root.addWidget(left)
        root.addWidget(right)
        root.leftchild = left
        root.rightchild = right

        return root, left, right