1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest
.framework
import UITestCase
10 from uitest
.uihelper
.common
import get_state_as_dict
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
13 class goToSheet(UITestCase
):
14 def test_go_to_sheet(self
):
15 with self
.ui_test
.create_doc_in_start_center("calc"):
17 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
18 xGridWindow
= xCalcDoc
.getChild("grid_window")
21 with self
.ui_test
.execute_dialog_through_command(".uno:Insert"):
24 with self
.ui_test
.execute_dialog_through_command(".uno:RenameTable") as xDialogRename
:
25 xname_entry
= xDialogRename
.getChild("name_entry")
26 xname_entry
.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"}))
28 with self
.ui_test
.execute_dialog_through_command(".uno:JumpToTable") as xDialogGoToSheet
:
29 xentry_mask
= xDialogGoToSheet
.getChild("entry-mask")
30 xtree_view
= xDialogGoToSheet
.getChild("treeview")
32 # Empty mask lists all sheets
33 self
.assertEqual(get_state_as_dict(xtree_view
)["Children"], "4")
35 # None sheet contains 'E': Search entry is case sensitive
36 xentry_mask
.executeAction("TYPE", mkPropertyValues({"TEXT":"E"}))
37 self
.assertEqual(get_state_as_dict(xtree_view
)["Children"], "0")
39 xentry_mask
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
40 self
.assertEqual(get_state_as_dict(xtree_view
)["Children"], "4")
42 # All sheets contains 'e'
43 xentry_mask
.executeAction("TYPE", mkPropertyValues({"TEXT":"e"}))
44 self
.assertEqual(get_state_as_dict(xtree_view
)["Children"], "4")
46 # List Sheet3, Sheet2 and Sheet1
47 xentry_mask
.executeAction("TYPE", mkPropertyValues({"TEXT":"e"}))
48 self
.assertEqual(get_state_as_dict(xtree_view
)["Children"], "3")
50 #if no name selected, active sheet remains unchanged
51 self
.assertEqual(get_state_as_dict(xGridWindow
)["SelectedTable"], "0")
53 with self
.ui_test
.execute_dialog_through_command(".uno:JumpToTable") as xDialogGoToSheet
:
54 xentry_mask
= xDialogGoToSheet
.getChild("entry-mask")
55 xtree_view
= xDialogGoToSheet
.getChild("treeview")
56 # List Sheet3, Sheet2 and Sheet1
57 xentry_mask
.executeAction("TYPE", mkPropertyValues({"TEXT":"ee"}))
58 self
.assertEqual(get_state_as_dict(xtree_view
)["Children"], "3")
60 xtree_view
.getChild('1').executeAction("SELECT", tuple())
62 self
.assertEqual(get_state_as_dict(xGridWindow
)["SelectedTable"], "2")
64 # vim: set shiftwidth=4 softtabstop=4 expandtab: