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 sheetRename(UITestCase
):
14 def test_sheet_rename(self
):
15 with self
.ui_test
.create_doc_in_start_center("calc"):
16 with self
.ui_test
.execute_dialog_through_command(".uno:RenameTable") as xDialog
:
17 xname_entry
= xDialog
.getChild("name_entry")
18 xname_entry
.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"}))
20 with self
.ui_test
.execute_dialog_through_command(".uno:RenameTable", close_button
="cancel") as xDialog
:
21 xname_entry
= xDialog
.getChild("name_entry")
22 self
.assertEqual(get_state_as_dict(xname_entry
)["Text"], "NewName")
25 def test_sheet_rename_invalid_sheet_name(self
):
26 with self
.ui_test
.create_doc_in_start_center("calc"):
27 with self
.ui_test
.execute_dialog_through_command(".uno:RenameTable", close_button
="") as xDialog
:
28 xname_entry
= xDialog
.getChild("name_entry")
29 nameVal
= get_state_as_dict(xname_entry
)["Text"]
30 xname_entry
.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName**"}))
31 xOKBtn
= xDialog
.getChild("ok")
33 with self
.ui_test
.execute_blocking_action(xOKBtn
.executeAction
, args
=('CLICK', ())):
36 xCancelBtn
= xDialog
.getChild("cancel")
37 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
40 with self
.ui_test
.execute_dialog_through_command(".uno:RenameTable") as xDialog
:
41 xname_entry
= xDialog
.getChild("name_entry")
42 self
.assertEqual(get_state_as_dict(xname_entry
)["Text"], nameVal
)
45 # def test_tdf81431_rename_sheet_clipboard_content_wiped_out(self):
46 # calc_doc = self.ui_test.create_doc_in_start_center("calc")
47 # xCalcDoc = self.xUITest.getTopFocusWindow()
48 # gridwin = xCalcDoc.getChild("grid_window")
49 # document = self.ui_test.get_component()
50 # #enter text and copy text to clipboard
51 # enter_text_to_cell(gridwin, "A1", "String")
52 # gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
53 # self.xUITest.executeCommand(".uno:Copy")
55 # self.ui_test.execute_dialog_through_command(".uno:RenameTable")
56 # xDialog = self.xUITest.getTopFocusWindow()
57 # xname_entry = xDialog.getChild("name_entry")
58 # nameVal = get_state_as_dict(xname_entry)["Text"]
59 # xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
60 # xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
61 # xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+V"}))
63 # #fails here - text is not pasted
64 # self.assertEqual(get_state_as_dict(xname_entry)["Text"], "String")
66 # xOKBtn = xDialog.getChild("ok")
67 # self.ui_test.close_dialog_through_button(xOKBtn)
69 # gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
70 # self.xUITest.executeCommand(".uno:Paste")
71 # self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "String")
73 # self.xUITest.executeCommand(".uno:Undo")
74 # self.xUITest.executeCommand(".uno:Undo")
75 # #verify undo cell paste
76 # self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "")
77 # #verify undo sheet rename
78 # self.ui_test.execute_dialog_through_command(".uno:RenameTable")
79 # xDialog = self.xUITest.getTopFocusWindow()
80 # xname_entry = xDialog.getChild("name_entry")
81 # self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal)
82 # xOKBtn = xDialog.getChild("ok")
83 # self.ui_test.close_dialog_through_button(xOKBtn)
85 # self.ui_test.close_doc()
86 # vim: set shiftwidth=4 softtabstop=4 expandtab: