summaryrefslogtreecommitdiffstats
path: root/sc/qa/uitest/protect
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sc/qa/uitest/protect
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/qa/uitest/protect')
-rw-r--r--sc/qa/uitest/protect/protectSheet.py52
-rw-r--r--sc/qa/uitest/protect/protectSpreadsheet.py32
2 files changed, 84 insertions, 0 deletions
diff --git a/sc/qa/uitest/protect/protectSheet.py b/sc/qa/uitest/protect/protectSheet.py
new file mode 100644
index 000000000..4b65e3b9e
--- /dev/null
+++ b/sc/qa/uitest/protect/protectSheet.py
@@ -0,0 +1,52 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
+from uitest.uihelper.common import get_state_as_dict
+
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+
+class protectSheet(UITestCase):
+ def test_protect_sheet(self):
+ with self.ui_test.create_doc_in_start_center("calc") as document:
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ #enter password - lock
+ with self.ui_test.execute_dialog_through_command(".uno:Protect") as xDialog:
+ xprotect = xDialog.getChild("protect")
+ xpassword1 = xDialog.getChild("password1")
+ xpassword2 = xDialog.getChild("password2")
+
+ if (get_state_as_dict(xprotect)["Selected"]) == "false":
+ xprotect.executeAction("CLICK", tuple())
+ xpassword1.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
+ xpassword2.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
+
+ #Unlock
+
+ with self.ui_test.execute_dialog_through_command(".uno:Protect") as xDialog:
+ xpass1ed = xDialog.getChild("pass1ed")
+
+ xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
+
+ #Verify - the sheet is unlocked
+ enter_text_to_cell(gridwin, "B2", "A")
+ self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "A")
+
+ # test cancel button
+ with self.ui_test.execute_dialog_through_command(".uno:Protect", close_button="cancel"):
+ pass
+
+ enter_text_to_cell(gridwin, "B2", "B")
+ self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B")
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/protect/protectSpreadsheet.py b/sc/qa/uitest/protect/protectSpreadsheet.py
new file mode 100644
index 000000000..bb4a471ac
--- /dev/null
+++ b/sc/qa/uitest/protect/protectSpreadsheet.py
@@ -0,0 +1,32 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+from uitest.framework import UITestCase
+
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+
+class protectSpreadsheet(UITestCase):
+ def test_protect_spreadsheet(self):
+ with self.ui_test.create_doc_in_start_center("calc"):
+ #enter password
+ with self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument") as xDialog:
+ xpass1ed = xDialog.getChild("pass1ed")
+ xconfirm1ed = xDialog.getChild("confirm1ed")
+
+ xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
+ xconfirm1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
+
+ #Verify
+ with self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument", close_button="cancel") as xDialog:
+ xpass1ed = xDialog.getChild("pass1ed")
+
+ xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: