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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# -*- 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.common import change_measurement_unit
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
#Chart Display Titles dialog
class chartTitles(UITestCase):
def test_chart_display_titles_dialog(self):
with self.ui_test.load_file(get_url_for_data_file("tdf98390.ods")) as calc_doc:
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
xCS = calc_doc.Sheets[0].Charts[0].getEmbeddedObject().FirstDiagram.CoordinateSystems[0]
self.assertFalse(calc_doc.Sheets[0].Charts[0].getEmbeddedObject().HasMainTitle)
self.assertFalse(calc_doc.Sheets[0].Charts[0].getEmbeddedObject().HasSubTitle)
self.assertIsNone(xCS.getAxisByDimension(0, 0).TitleObject)
self.assertIsNone(xCS.getAxisByDimension(1, 0).TitleObject)
gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
gridwin.executeAction("ACTIVATE", tuple())
xChartMainTop = self.xUITest.getTopFocusWindow()
xChartMain = xChartMainTop.getChild("chart_window")
xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuTitles"})) as xDialog:
maintitle = xDialog.getChild("maintitle")
subtitle = xDialog.getChild("subtitle")
primaryXaxis = xDialog.getChild("primaryXaxis")
primaryYaxis = xDialog.getChild("primaryYaxis")
secondaryXaxis = xDialog.getChild("secondaryXaxis")
secondaryYaxis = xDialog.getChild("secondaryYaxis")
maintitle.executeAction("TYPE", mkPropertyValues({"TEXT":"A"}))
subtitle.executeAction("TYPE", mkPropertyValues({"TEXT":"B"}))
primaryXaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"C"}))
primaryYaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"D"}))
secondaryXaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"E"}))
secondaryYaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"F"}))
self.assertTrue(calc_doc.Sheets[0].Charts[0].getEmbeddedObject().HasMainTitle)
self.assertTrue(calc_doc.Sheets[0].Charts[0].getEmbeddedObject().HasSubTitle)
self.assertEqual("A", calc_doc.Sheets[0].Charts[0].getEmbeddedObject().Title.String)
self.assertEqual("B", calc_doc.Sheets[0].Charts[0].getEmbeddedObject().SubTitle.String)
self.assertEqual("C", xCS.getAxisByDimension(0, 0).TitleObject.Text[0].String)
self.assertEqual("D", xCS.getAxisByDimension(1, 0).TitleObject.Text[0].String)
self.assertEqual("E", xCS.getAxisByDimension(0, 1).TitleObject.Text[0].String)
self.assertEqual("F", xCS.getAxisByDimension(1, 1).TitleObject.Text[0].String)
#reopen and verify InsertMenuTitles dialog
gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
gridwin.executeAction("ACTIVATE", tuple())
xChartMainTop = self.xUITest.getTopFocusWindow()
xChartMain = xChartMainTop.getChild("chart_window")
xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuTitles"})) as xDialog:
maintitle = xDialog.getChild("maintitle")
subtitle = xDialog.getChild("subtitle")
primaryXaxis = xDialog.getChild("primaryXaxis")
primaryYaxis = xDialog.getChild("primaryYaxis")
secondaryXaxis = xDialog.getChild("secondaryXaxis")
secondaryYaxis = xDialog.getChild("secondaryYaxis")
self.assertEqual(get_state_as_dict(maintitle)["Text"], "A")
self.assertEqual(get_state_as_dict(subtitle)["Text"], "B")
self.assertEqual(get_state_as_dict(primaryXaxis)["Text"], "C")
self.assertEqual(get_state_as_dict(primaryYaxis)["Text"], "D")
self.assertEqual(get_state_as_dict(secondaryXaxis)["Text"], "E")
self.assertEqual(get_state_as_dict(secondaryYaxis)["Text"], "F")
def test_title_move_with_arrows_keys(self):
with self.ui_test.load_file(get_url_for_data_file("chartArea.ods")):
with change_measurement_unit(self, "Centimeter"):
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
gridwin.executeAction("ACTIVATE", tuple())
xChartMainTop = self.xUITest.getTopFocusWindow()
xChartMain = xChartMainTop.getChild("chart_window")
# Select the title
xTitle = xChartMain.getChild("CID/Title=")
xTitle.executeAction("SELECT", tuple())
with self.ui_test.execute_dialog_through_action(xTitle, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
self.assertEqual("3.52", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
self.assertEqual("0.3", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
with self.ui_test.execute_dialog_through_action(xTitle, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
# Check the position has changed after moving the title using the arrows keys
self.assertEqual("3.42", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
self.assertEqual("0.2", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|