uitest ProtectSheet, protectSpreadsheet, clearCells, tdf#101904

Change-Id: I18f5563be60fa7826d8f720288abcfaf9d93313e
Reviewed-on: https://gerrit.libreoffice.org/56564
Tested-by: Jenkins
Reviewed-by: Zdenek Crhonek <zcrhonek@gmail.com>
This commit is contained in:
Zdeněk Crhonek
2018-06-27 21:56:55 +02:00
committed by Zdenek Crhonek
parent df579bea05
commit 681b3facd3
5 changed files with 408 additions and 0 deletions

View File

@@ -191,6 +191,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sc,\
UITest_statistics \
UITest_solver \
UITest_goalSeek \
UITest_protect \
))
endif

20
sc/UITest_protect.mk Normal file
View File

@@ -0,0 +1,20 @@
# -*- 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/.
#
$(eval $(call gb_UITest_UITest,protect))
$(eval $(call gb_UITest_add_modules,protect,$(SRCDIR)/sc/qa/uitest,\
protect/ \
))
$(eval $(call gb_UITest_set_defs,protect, \
TDOC="$(SRCDIR)/sc/qa/uitest/calc_tests/data" \
))
# vim: set noet sw=4 ts=4:

View File

@@ -0,0 +1,287 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# 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.common import get_state_as_dict
from uitest.uihelper.common import select_pos
from uitest.uihelper.calc import enter_text_to_cell
from libreoffice.calc.document import get_sheet_from_doc
from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
from uitest.debug import sleep
from libreoffice.calc.document import get_cell_by_position
from libreoffice.uno.propertyvalue import mkPropertyValues
#deletecontents.ui
#+ Bug 101904 - Delete Contents dialog -- won't delete cell content "Date & time"
class clearCells(UITestCase):
def test_clear_cells_text(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
enter_text_to_cell(gridwin, "A1", "aa")
enter_text_to_cell(gridwin, "A2", "1")
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
self.ui_test.execute_dialog_through_command(".uno:Delete")
xDialog = self.xUITest.getTopFocusWindow()
xdeleteall = xDialog.getChild("deleteall")
xtext = xDialog.getChild("text")
xdatetime = xDialog.getChild("datetime")
xcomments = xDialog.getChild("comments")
xobjects = xDialog.getChild("objects")
xnumbers = xDialog.getChild("numbers")
xformulas = xDialog.getChild("formulas")
xformats = xDialog.getChild("formats")
if (get_state_as_dict(xdeleteall)["Selected"]) == "true":
xdeleteall.executeAction("CLICK", tuple())
if (get_state_as_dict(xtext)["Selected"]) == "false":
xtext.executeAction("CLICK", tuple())
if (get_state_as_dict(xdatetime)["Selected"]) == "true":
xdatetime.executeAction("CLICK", tuple())
if (get_state_as_dict(xcomments)["Selected"]) == "true":
xcomments.executeAction("CLICK", tuple())
if (get_state_as_dict(xobjects)["Selected"]) == "true":
xobjects.executeAction("CLICK", tuple())
if (get_state_as_dict(xnumbers)["Selected"]) == "true":
xnumbers.executeAction("CLICK", tuple())
if (get_state_as_dict(xformulas)["Selected"]) == "true":
xformulas.executeAction("CLICK", tuple())
if (get_state_as_dict(xformats)["Selected"]) == "true":
xformats.executeAction("CLICK", tuple())
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "")
self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1)
self.ui_test.close_doc()
def test_clear_cells_date_tdf101904(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
enter_text_to_cell(gridwin, "A1", "01/01/2000")
enter_text_to_cell(gridwin, "A2", "1")
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
self.ui_test.execute_dialog_through_command(".uno:Delete")
xDialog = self.xUITest.getTopFocusWindow()
xdeleteall = xDialog.getChild("deleteall")
xtext = xDialog.getChild("text")
xdatetime = xDialog.getChild("datetime")
xcomments = xDialog.getChild("comments")
xobjects = xDialog.getChild("objects")
xnumbers = xDialog.getChild("numbers")
xformulas = xDialog.getChild("formulas")
xformats = xDialog.getChild("formats")
if (get_state_as_dict(xdeleteall)["Selected"]) == "true":
xdeleteall.executeAction("CLICK", tuple())
if (get_state_as_dict(xtext)["Selected"]) == "true":
xtext.executeAction("CLICK", tuple())
if (get_state_as_dict(xdatetime)["Selected"]) == "false":
xdatetime.executeAction("CLICK", tuple())
if (get_state_as_dict(xcomments)["Selected"]) == "true":
xcomments.executeAction("CLICK", tuple())
if (get_state_as_dict(xobjects)["Selected"]) == "true":
xobjects.executeAction("CLICK", tuple())
if (get_state_as_dict(xnumbers)["Selected"]) == "true":
xnumbers.executeAction("CLICK", tuple())
if (get_state_as_dict(xformulas)["Selected"]) == "true":
xformulas.executeAction("CLICK", tuple())
if (get_state_as_dict(xformats)["Selected"]) == "true":
xformats.executeAction("CLICK", tuple())
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "")
self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1)
self.ui_test.close_doc()
def test_clear_cells_number(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
enter_text_to_cell(gridwin, "A1", "aa")
enter_text_to_cell(gridwin, "A2", "1")
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
self.ui_test.execute_dialog_through_command(".uno:Delete")
xDialog = self.xUITest.getTopFocusWindow()
xdeleteall = xDialog.getChild("deleteall")
xtext = xDialog.getChild("text")
xdatetime = xDialog.getChild("datetime")
xcomments = xDialog.getChild("comments")
xobjects = xDialog.getChild("objects")
xnumbers = xDialog.getChild("numbers")
xformulas = xDialog.getChild("formulas")
xformats = xDialog.getChild("formats")
if (get_state_as_dict(xdeleteall)["Selected"]) == "true":
xdeleteall.executeAction("CLICK", tuple())
if (get_state_as_dict(xtext)["Selected"]) == "true":
xtext.executeAction("CLICK", tuple())
if (get_state_as_dict(xdatetime)["Selected"]) == "true":
xdatetime.executeAction("CLICK", tuple())
if (get_state_as_dict(xcomments)["Selected"]) == "true":
xcomments.executeAction("CLICK", tuple())
if (get_state_as_dict(xobjects)["Selected"]) == "true":
xobjects.executeAction("CLICK", tuple())
if (get_state_as_dict(xnumbers)["Selected"]) == "false":
xnumbers.executeAction("CLICK", tuple())
if (get_state_as_dict(xformulas)["Selected"]) == "true":
xformulas.executeAction("CLICK", tuple())
if (get_state_as_dict(xformats)["Selected"]) == "true":
xformats.executeAction("CLICK", tuple())
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa")
self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 0)
self.ui_test.close_doc()
def test_clear_cells_formulas(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
enter_text_to_cell(gridwin, "A1", "1")
enter_text_to_cell(gridwin, "A2", "=A1+1")
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
self.ui_test.execute_dialog_through_command(".uno:Delete")
xDialog = self.xUITest.getTopFocusWindow()
xdeleteall = xDialog.getChild("deleteall")
xtext = xDialog.getChild("text")
xdatetime = xDialog.getChild("datetime")
xcomments = xDialog.getChild("comments")
xobjects = xDialog.getChild("objects")
xnumbers = xDialog.getChild("numbers")
xformulas = xDialog.getChild("formulas")
xformats = xDialog.getChild("formats")
if (get_state_as_dict(xdeleteall)["Selected"]) == "true":
xdeleteall.executeAction("CLICK", tuple())
if (get_state_as_dict(xtext)["Selected"]) == "true":
xtext.executeAction("CLICK", tuple())
if (get_state_as_dict(xdatetime)["Selected"]) == "true":
xdatetime.executeAction("CLICK", tuple())
if (get_state_as_dict(xcomments)["Selected"]) == "true":
xcomments.executeAction("CLICK", tuple())
if (get_state_as_dict(xobjects)["Selected"]) == "true":
xobjects.executeAction("CLICK", tuple())
if (get_state_as_dict(xnumbers)["Selected"]) == "true":
xnumbers.executeAction("CLICK", tuple())
if (get_state_as_dict(xformulas)["Selected"]) == "false":
xformulas.executeAction("CLICK", tuple())
if (get_state_as_dict(xformats)["Selected"]) == "true":
xformats.executeAction("CLICK", tuple())
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "1")
self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "")
self.ui_test.close_doc()
def test_clear_cells_formats(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
enter_text_to_cell(gridwin, "A1", "aa")
enter_text_to_cell(gridwin, "A2", "1")
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
self.xUITest.executeCommand(".uno:Bold")
self.ui_test.execute_dialog_through_command(".uno:Delete")
xDialog = self.xUITest.getTopFocusWindow()
xdeleteall = xDialog.getChild("deleteall")
xtext = xDialog.getChild("text")
xdatetime = xDialog.getChild("datetime")
xcomments = xDialog.getChild("comments")
xobjects = xDialog.getChild("objects")
xnumbers = xDialog.getChild("numbers")
xformulas = xDialog.getChild("formulas")
xformats = xDialog.getChild("formats")
if (get_state_as_dict(xdeleteall)["Selected"]) == "true":
xdeleteall.executeAction("CLICK", tuple())
if (get_state_as_dict(xtext)["Selected"]) == "true":
xtext.executeAction("CLICK", tuple())
if (get_state_as_dict(xdatetime)["Selected"]) == "true":
xdatetime.executeAction("CLICK", tuple())
if (get_state_as_dict(xcomments)["Selected"]) == "true":
xcomments.executeAction("CLICK", tuple())
if (get_state_as_dict(xobjects)["Selected"]) == "true":
xobjects.executeAction("CLICK", tuple())
if (get_state_as_dict(xnumbers)["Selected"]) == "true":
xnumbers.executeAction("CLICK", tuple())
if (get_state_as_dict(xformulas)["Selected"]) == "true":
xformulas.executeAction("CLICK", tuple())
if (get_state_as_dict(xformats)["Selected"]) == "false":
xformats.executeAction("CLICK", tuple())
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
xDialog = self.xUITest.getTopFocusWindow()
xTabs = xDialog.getChild("tabcontrol")
select_pos(xTabs, "1") #tab Font
xstylelb = xDialog.getChild("weststylelb-cjk")
print(get_state_as_dict(xstylelb))
self.assertEqual(get_state_as_dict(xstylelb)["Text"], "Regular")
xOK = xDialog.getChild("ok")
xOK.executeAction("CLICK", tuple())
self.ui_test.close_doc()
def test_clear_cells_all(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
enter_text_to_cell(gridwin, "A1", "aa")
enter_text_to_cell(gridwin, "A2", "1")
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
self.xUITest.executeCommand(".uno:Bold")
self.ui_test.execute_dialog_through_command(".uno:Delete")
xDialog = self.xUITest.getTopFocusWindow()
xdeleteall = xDialog.getChild("deleteall")
xtext = xDialog.getChild("text")
xdatetime = xDialog.getChild("datetime")
xcomments = xDialog.getChild("comments")
xobjects = xDialog.getChild("objects")
xnumbers = xDialog.getChild("numbers")
xformulas = xDialog.getChild("formulas")
xformats = xDialog.getChild("formats")
if (get_state_as_dict(xdeleteall)["Selected"]) == "false":
xdeleteall.executeAction("CLICK", tuple())
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "")
self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "")
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -0,0 +1,54 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# 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.common import get_state_as_dict
from uitest.uihelper.common import select_pos
from uitest.uihelper.calc import enter_text_to_cell
from libreoffice.calc.document import get_sheet_from_doc
from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
from uitest.debug import sleep
from libreoffice.calc.document import get_cell_by_position
from libreoffice.uno.propertyvalue import mkPropertyValues
class protectSheet(UITestCase):
def test_protect_sheet(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
#enter password - lock
self.ui_test.execute_dialog_through_command(".uno:Protect")
xDialog = self.xUITest.getTopFocusWindow()
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"}))
xOKBtn = xDialog.getChild("ok")
# self.ui_test.close_dialog_through_button(xOKBtn)
xOKBtn.executeAction("CLICK", tuple())
#Unlock
self.ui_test.execute_dialog_through_command(".uno:Protect")
xDialog = self.xUITest.getTopFocusWindow()
xpass1ed = xDialog.getChild("pass1ed")
xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify - the sheet is unlocked
enter_text_to_cell(gridwin, "B2", "A")
self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "A")
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -0,0 +1,46 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# 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.common import get_state_as_dict
from uitest.uihelper.common import select_pos
from uitest.uihelper.calc import enter_text_to_cell
from libreoffice.calc.document import get_sheet_from_doc
from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
from uitest.debug import sleep
from libreoffice.calc.document import get_cell_by_position
from libreoffice.uno.propertyvalue import mkPropertyValues
class protectSpreadsheet(UITestCase):
def test_protect_spreadsheet(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
#enter password
self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument")
xDialog = self.xUITest.getTopFocusWindow()
xpass1ed = xDialog.getChild("pass1ed")
xconfirm1ed = xDialog.getChild("confirm1ed")
xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
xconfirm1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument")
xDialog = self.xUITest.getTopFocusWindow()
xpass1ed = xDialog.getChild("pass1ed")
xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"}))
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab: