summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdeněk Crhonek <zcrhonek@gmail.com>2018-08-20 15:43:17 +0200
committerZdenek Crhonek <zcrhonek@gmail.com>2018-08-21 17:35:00 +0200
commit55d1ee5a8fb3e72d534a64e5045dfc0ec6a6eab8 (patch)
treebe52988fa09c6bc78dbf0406d595aff5b086c262
parentc4651bf0b75e3178efa2ac472ec4ed225176bbfd (diff)
uitest Calc-Text Case; tdf#119155 ; tdf#119162
Change-Id: Ifaf90b8bcf37bc712f734778a935370027696210 Reviewed-on: https://gerrit.libreoffice.org/59328 Tested-by: Jenkins Reviewed-by: Zdenek Crhonek <zcrhonek@gmail.com>
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/UITest_textCase.mk20
-rw-r--r--sc/qa/uitest/calc_tests/data/tdf119155.xlsxbin0 -> 5944 bytes
-rw-r--r--sc/qa/uitest/calc_tests/data/tdf119162.xlsbin0 -> 5632 bytes
-rw-r--r--sc/qa/uitest/textCase/textCase.py165
5 files changed, 186 insertions, 0 deletions
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 9109cc730b64..ab21903dfd7c 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -196,6 +196,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sc,\
UITest_options \
UITest_validity \
UITest_key_f4 \
+ UITest_textCase \
))
endif
diff --git a/sc/UITest_textCase.mk b/sc/UITest_textCase.mk
new file mode 100644
index 000000000000..dc55550cbedf
--- /dev/null
+++ b/sc/UITest_textCase.mk
@@ -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,textCase))
+
+$(eval $(call gb_UITest_add_modules,textCase,$(SRCDIR)/sc/qa/uitest,\
+ textCase/ \
+))
+
+$(eval $(call gb_UITest_set_defs,textCase, \
+ TDOC="$(SRCDIR)/sc/qa/uitest/calc_tests/data" \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/qa/uitest/calc_tests/data/tdf119155.xlsx b/sc/qa/uitest/calc_tests/data/tdf119155.xlsx
new file mode 100644
index 000000000000..8deb480f79e0
--- /dev/null
+++ b/sc/qa/uitest/calc_tests/data/tdf119155.xlsx
Binary files differ
diff --git a/sc/qa/uitest/calc_tests/data/tdf119162.xls b/sc/qa/uitest/calc_tests/data/tdf119162.xls
new file mode 100644
index 000000000000..42765fbe9000
--- /dev/null
+++ b/sc/qa/uitest/calc_tests/data/tdf119162.xls
Binary files differ
diff --git a/sc/qa/uitest/textCase/textCase.py b/sc/qa/uitest/textCase/textCase.py
new file mode 100644
index 000000000000..fede2a78a024
--- /dev/null
+++ b/sc/qa/uitest/textCase/textCase.py
@@ -0,0 +1,165 @@
+# -*- 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_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+import org.libreoffice.unotest
+import pathlib
+def get_url_for_data_file(file_name):
+ return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+class textCase(UITestCase):
+ def test_text_case_switch(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 data
+ enter_text_to_cell(gridwin, "A1", "hello world")
+ enter_text_to_cell(gridwin, "A2", "libre office")
+ enter_text_to_cell(gridwin, "A4", "free suite")
+ #select
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"}))
+ #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase
+ self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
+ #Verify
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite")
+
+ #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase
+ self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase")
+
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite")
+
+ #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase
+ self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE")
+
+ #uppercase = CommandSent Name:.uno:ChangeCaseToUpper
+ self.xUITest.executeCommand(".uno:ChangeCaseToUpper")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE")
+
+ #lowercase - CommandSent Name:.uno:ChangeCaseToLower
+ self.xUITest.executeCommand(".uno:ChangeCaseToLower")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite")
+
+ #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase
+ self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite")
+
+ #select non continuous range
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B2"}))
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:A5", "EXTEND":"1"}))
+
+ #lowercase - CommandSent Name:.uno:ChangeCaseToLower
+ self.xUITest.executeCommand(".uno:ChangeCaseToLower")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite")
+
+ #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase
+ self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
+ #Verify
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite")
+
+ #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase
+ self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase")
+
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite")
+
+ #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase
+ self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE")
+
+ #uppercase = CommandSent Name:.uno:ChangeCaseToUpper
+ self.xUITest.executeCommand(".uno:ChangeCaseToUpper")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE")
+
+ #lowercase - CommandSent Name:.uno:ChangeCaseToLower
+ self.xUITest.executeCommand(".uno:ChangeCaseToLower")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite")
+
+ #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase
+ self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
+ self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite")
+ self.ui_test.close_doc()
+
+ def test_tdf119155_Capitalize_Every_Word(self):
+ #Bug 119155 - Freeze after command format->text->Capitalize Every Word
+ calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf119155.xlsx"))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+ #1. Open attached file
+ #2. Select cels from C2 to C14
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C2:C14"}))
+ #3. Go to menu: Format->Text->Capitalize Every Word
+ self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
+ #Actual Results:Freezes LibreOffice
+ self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "Collagene Expert Targeted Wrinkle Corrector Unboxed 10 Ml")
+ self.assertEqual(get_cell_by_position(document, 0, 2, 13).getString(), "Vitamina Suractivee Hand Cream 400 Ml")
+
+ self.ui_test.close_doc()
+
+ def test_tdf119162_Cycle_Case(self):
+ #Bug 119162 - Format > Text > Cycle Case on attached example file hangs Calc reproducibly
+ calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf119162.xls"))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+ #1.Open the attached .xls file
+ #2. Select column A
+ gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+ #3. Select [Format] > [Text] > [Cycle Case]
+ self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
+ self.xUITest.executeCommand(".uno:ChangeCaseToLower")
+ #Actual Results:Freezes LibreOffice
+ self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "test\n")
+
+ self.ui_test.close_doc()
+# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file