tdf#147394: sc: Add UItest

Change-Id: I0fa20d777247501593ac80ab394407d0570763bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129910
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/uitest/chart/chartLegend.py b/sc/qa/uitest/chart/chartLegend.py
index 8bea7f1..4372e47 100644
--- a/sc/qa/uitest/chart/chartLegend.py
+++ b/sc/qa/uitest/chart/chartLegend.py
@@ -104,4 +104,27 @@ class chartLegend(UITestCase):
        self.assertEqual("4.51", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
        self.assertEqual("1.44", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])

   def test_Tdf147394(self):

    with self.ui_test.load_file(get_url_for_data_file("dataLabels.ods")) as calc_doc:
      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")

      xLegend = calc_doc.Sheets[0].Charts[0].getEmbeddedObject().getFirstDiagram().Legend
      self.assertTrue(xLegend.Show)

      # Select the legends
      xLegends = xChartMain.getChild("CID/D=0:Legend=")
      xLegends.executeAction("SELECT", tuple())

      # Without the fix in place, this test would have crashed here
      xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"}))

      self.assertFalse(xLegend.Show)

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