diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2015-06-08 10:24:42 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2015-06-23 06:38:56 +0000 |
commit | 187445b2d2885ced92be37ffb11cd2a9bb11f8d6 (patch) | |
tree | 1aef8d03508376156d4f987083a9f148da4602f5 /sfx2/qa/python | |
parent | 77cc71476bae2b3655102e2c29d36af40a393201 (diff) |
Uno api sidebar unit test tdf#91806
- python test subsequentcheck
- correct deck setTitle APi (UI update)
- enhance UnoInProcess for flexiility in loading parameter
Change-Id: Id04cb78c6162ac84fb3bfd8577f84763109d993e
Reviewed-on: https://gerrit.libreoffice.org/16180
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2/qa/python')
-rw-r--r-- | sfx2/qa/python/check_sidebar.py | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/sfx2/qa/python/check_sidebar.py b/sfx2/qa/python/check_sidebar.py new file mode 100644 index 000000000000..355951a3037e --- /dev/null +++ b/sfx2/qa/python/check_sidebar.py @@ -0,0 +1,149 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import unittest +import unohelper +import os +from org.libreoffice.unotest import UnoInProcess + +from com.sun.star.ui import XSidebarProvider +from com.sun.star.ui import XDecks +from com.sun.star.ui import XDeck +from com.sun.star.ui import XPanels +from com.sun.star.ui import XPanel + +class CheckSidebar(unittest.TestCase): + _uno = None + _xDoc = None + + @classmethod + def setUpClass(cls): + cls._uno = UnoInProcess() + cls._uno.setUp() + cls._xDoc = cls._uno.openEmptyDoc( url = "private:factory/scalc", bHidden = False, bReadOnly = False) + + @classmethod + def tearDownClass(cls): + cls._uno.tearDown() + + def test_check_sidebar(self): + + xDoc = self.__class__._xDoc + xController = xDoc.getCurrentController() + + xSidebar = xController.getSidebar() + assert(xSidebar) + + xSidebar.setVisible(True) + isVisible = xSidebar.isVisible() + self.assertTrue ( xSidebar.isVisible() ) + + # TODO: does not work in unit test context +# xSidebar.setVisible(False) +# isVisible = xSidebar.isVisible() +# assert( not isVisible ) +# xSidebar.setVisible(True) + + xSidebar.showDecks(False) + xSidebar.showDecks(True) + + xDecks = xSidebar.getDecks() + + firstDeckName = "PropertyDeck"; + + deckElementNames = xDecks.getElementNames() + assert ( firstDeckName in deckElementNames ) + assert ( xDecks.hasByName(firstDeckName) ) + + decksCount = xDecks.getCount() + self.assertEqual ( 5, decksCount ) + + xDeck = xDecks.getByName(firstDeckName) + assert ( xDeck ) + assert ( xDeck.getId() == firstDeckName ) + + newDeckTitle = "New title" + xDeck.setTitle(newDeckTitle) + assert ( xDeck.getTitle() == newDeckTitle ) + + xDeck.moveFirst() + initialIndex = xDeck.getOrderIndex() + self.assertEqual(100, initialIndex) + + xDeck.moveLast() + assert ( xDeck.getOrderIndex() > initialIndex ) + + initialIndex = xDeck.getOrderIndex() + xDeck.moveFirst() + assert ( xDeck.getOrderIndex() < initialIndex ) + + initialIndex = xDeck.getOrderIndex() + xDeck.moveDown() + assert ( xDeck.getOrderIndex() > initialIndex ) + + initialIndex = xDeck.getOrderIndex() + xDeck.moveUp() + assert ( xDeck.getOrderIndex() < initialIndex ) + + xPanels = xDeck.getPanels() + + panelsCount = xPanels.getCount() + self.assertEqual ( panelsCount, 4 ) + + firstPanelName = "TextPropertyPanel" + + panelElementNames = xPanels.getElementNames() + assert ( firstPanelName in panelElementNames ) + assert ( xPanels.hasByName(firstPanelName) ) + + xPanel = xPanels.getByName(firstPanelName) + assert ( xPanel ) + assert ( xPanel.getId() == firstPanelName ) + + newTitle = "New title" + xPanel.setTitle(newTitle) + assert ( xPanel.getTitle() == newTitle ) + + xPanel.moveFirst() + initialIndex = xPanel.getOrderIndex() + assert ( initialIndex == 120 ) + + xPanel.moveLast() + assert ( xPanel.getOrderIndex() > initialIndex ) + + initialIndex = xPanel.getOrderIndex() + xPanel.moveFirst() + assert ( xPanel.getOrderIndex() < initialIndex ) + + initialIndex = xPanel.getOrderIndex() + xPanel.moveDown() + assert ( xPanel.getOrderIndex() > initialIndex ) + + initialIndex = xPanel.getOrderIndex() + xPanel.moveUp() + assert ( xPanel.getOrderIndex() < initialIndex ) + + xPanel.collapse() + assert( not xPanel.isExpanded() ) + + otherPanel = xPanels.getByName("NumberFormatPropertyPanel") + otherPanel.expand(False) + assert( otherPanel.isExpanded() ) + + xPanel.expand(True) + assert( xPanel.isExpanded() ) + assert( not otherPanel.isExpanded() ) + + # close the document + xDoc.dispose() + +if __name__ == "__main__": + unittest.main() + +# vim: set noet sw=4 ts=4:
\ No newline at end of file |