summaryrefslogtreecommitdiff
path: root/sc/qa/uitest/chart/tdf101894.py
blob: 419b9c645addc37fa1f4a5e8fb324c6114d40f3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
from uitest.uihelper.common import get_state_as_dict

class tdf101894(UITestCase):

  def test_tdf101894(self):
    with self.ui_test.load_file(get_url_for_data_file("tdf101894.ods")) as calc_doc:
        xCalcDoc = self.xUITest.getTopFocusWindow()
        gridwin = xCalcDoc.getChild("grid_window")


        xChart = calc_doc.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(2, len(xDS))
            xRow.append(xDS[0].Values.SourceRangeRepresentation)
            xRow.append(xDS[1].Values.SourceRangeRepresentation)
            xOldSheetRanges.append(xRow)

        # Rename the sheet first
        self.ui_test.execute_dialog_through_command(".uno:RenameTable")
        xDialog = self.xUITest.getTopFocusWindow()
        xname_entry = xDialog.getChild("name_entry")

        oldName = get_state_as_dict(xname_entry)['Text']
        xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
        xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
        xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"}))
        xOKBtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xOKBtn)

        # Copy sheet and use the old name
        self.ui_test.execute_dialog_through_command(".uno:Move")
        xDialog = self.xUITest.getTopFocusWindow()
        newName = xDialog.getChild("newName")
        newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
        newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
        newName.executeAction("TYPE", mkPropertyValues({"TEXT": oldName}))
        xOKBtn = xDialog.getChild("ok")
        self.ui_test.close_dialog_through_button(xOKBtn)

        xChart = calc_doc.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(2, len(xDS))
            xRow.append(xDS[0].Values.SourceRangeRepresentation)
            xRow.append(xDS[1].Values.SourceRangeRepresentation)
            xNewSheetRanges.append(xRow)

        self.assertEqual(xOldSheetRanges, xNewSheetRanges)

# vim: set shiftwidth=4 softtabstop=4 expandtab: