diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-02-16 16:10:08 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-02-16 21:20:02 +0100 |
commit | 752a6d58a440e2cb84e0f84d3e12dd52efd016eb (patch) | |
tree | bd7203d26ad81eef943e6e69205a0411d4e40b12 /sc | |
parent | ee6548117e617be0a2d4e87671db43a4f97d0027 (diff) |
uitest: sc: test charts are pasted in a new document...
... when the source sheet has a dot in the name
I found this problem while working on another UItest.
This started to work after b9652803096b68a33702601aac52e78c8a4250c6
Before this commit, the chart wasn't even pasted, due to
a2e6f31c6f90e446d1462e7c80f6b1317f7825bc. Before this commit,
the ranges in the pasted chart were incorrect. Not sure when this
issue got fixed though. Anyway, let's add a test for it
Change-Id: I152d569bfa04a0e3e6056e39b9ee59955bf9e1d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110993
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/uitest/chart/copyPaste.py | 75 | ||||
-rw-r--r-- | sc/qa/uitest/data/chartWithDotInSheetName.ods | bin | 0 -> 15057 bytes |
2 files changed, 75 insertions, 0 deletions
diff --git a/sc/qa/uitest/chart/copyPaste.py b/sc/qa/uitest/chart/copyPaste.py new file mode 100644 index 000000000000..9b4ba830cdf1 --- /dev/null +++ b/sc/qa/uitest/chart/copyPaste.py @@ -0,0 +1,75 @@ +# -*- 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 libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_url_for_data_file + +class CopyPaste(UITestCase): + + def test_copy_paste_chart_with_dot_in_sheet_name(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("chartWithDotInSheetName.ods")) + document = self.ui_test.get_component() + + xChart = document.Sheets[0].Charts[0] + xDataSeries = xChart.getEmbeddedObject().getFirstDiagram().CoordinateSystems[0].ChartTypes[0].DataSeries + + self.assertEqual(4, len(xDataSeries)) + + xOldSheetRanges = [] + for i in range(4): + xRow = [] + xDS = xDataSeries[i].DataSequences + + self.assertEqual(1, len(xDS)) + xRow.append(xDS[0].Values.SourceRangeRepresentation) + xOldSheetRanges.append(xRow) + + self.xUITest.executeCommand(".uno:SelectAll") + + self.xUITest.executeCommand(".uno:Copy") + + self.ui_test.close_doc() + + self.ui_test.load_empty_file("calc") + document = self.ui_test.get_component() + + # Rename the sheet to match the same name as the first document + self.ui_test.execute_dialog_through_command(".uno:RenameTable") + xDialog = self.xUITest.getTopFocusWindow() + xname_entry = xDialog.getChild("name_entry") + + xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"Sheet.1"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.xUITest.executeCommand(".uno:Paste") + + xChart = document.Sheets[0].Charts[0] + xDataSeries = xChart.getEmbeddedObject().getFirstDiagram().CoordinateSystems[0].ChartTypes[0].DataSeries + + self.assertEqual(4, len(xDataSeries)) + + xNewSheetRanges = [] + for i in range(4): + xRow = [] + xDS = xDataSeries[i].DataSequences + + self.assertEqual(1, len(xDS)) + xRow.append(xDS[0].Values.SourceRangeRepresentation) + xNewSheetRanges.append(xRow) + + # Without the fix in place, this test would have failed with + # ["$'Sheet.1'.$B$12:$B$18"] + # ["'file:///home/<user>/Documents/Sheet.1'#$Sheet1.$B$12:$B$18"] + self.assertEqual(xOldSheetRanges, xNewSheetRanges) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/chartWithDotInSheetName.ods b/sc/qa/uitest/data/chartWithDotInSheetName.ods Binary files differnew file mode 100644 index 000000000000..873d45f4be8c --- /dev/null +++ b/sc/qa/uitest/data/chartWithDotInSheetName.ods |