tdf#146260: sc: Add UItest

Change-Id: I1ff644745344cb847fd0b4c7b20551ad189cb383
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147081
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/uitest/calc_tests2/xmlSource.py b/sc/qa/uitest/calc_tests2/xmlSource.py
index 59a3abd..26ca9ce 100644
--- a/sc/qa/uitest/calc_tests2/xmlSource.py
+++ b/sc/qa/uitest/calc_tests2/xmlSource.py
@@ -89,4 +89,39 @@ class xmlSource(UITestCase):
            self.assertEqual("v2", get_cell_by_position(calc_doc, 0, 0, 2).getString())
            self.assertEqual("v3", get_cell_by_position(calc_doc, 0, 0, 3).getString())

    def test_tdf146260(self):

        with self.ui_test.create_doc_in_start_center("calc") as calc_doc:

            with self.ui_test.execute_modeless_dialog_through_command(".uno:ManageXMLSource") as xDialog:

                xSource = xDialog.getChild("selectsource")

                with self.ui_test.execute_blocking_action(xSource.executeAction, args=('CLICK', ()), close_button="open") as xOpenDialog:
                    xFileName = xOpenDialog.getChild("file_name")
                    xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf146260.xml")}))

                xTree = xDialog.getChild("tree")
                self.assertEqual('43', get_state_as_dict(xTree)["Children"])

                xTree.getChild('0').executeAction("SELECT", tuple())
                for i in range(5):
                    xTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))

                self.assertEqual("Fp", get_state_as_dict(xTree)["SelectEntryText"])
                self.assertEqual("38", get_state_as_dict(xTree)["SelectionCount"])

                xEdit = xDialog.getChild("edit")
                xEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "$A$1"}))

            # Without the fix in place, this test would have failed with
            # AssertionError: 'data' != ''
            self.assertEqual("Djh", get_cell_by_position(calc_doc, 0, 0, 0).getString())
            self.assertEqual("Fpzl", get_cell_by_position(calc_doc, 0, 1, 0).getString())

            for i in range(1, 5):
                # Without the fix in place, this test would have failed with
                # AssertionError: '专用发票' != 'ר�÷�Ʊ'
                self.assertEqual("专用发票", get_cell_by_position(calc_doc, 0, 1, i).getString())

# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf146260.xml b/sc/qa/uitest/data/tdf146260.xml
new file mode 100644
index 0000000..fc41f8d
--- /dev/null
+++ b/sc/qa/uitest/data/tdf146260.xml
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="GBK"?>
<Kp>
    <Version>2.0</Version>
    <Fpxx>
        <Zsl>43</Zsl>
        <Fpsj>
            <Fp>
                <Djh></Djh>
                <Fpzl>רÓ÷¢Æ±</Fpzl>
                <Lbdm>210***3130</Lbdm>
                <Fphm>01***724</Fphm>
                <Kprq>202***02</Kprq>
                <Gfmc>ÉϺ£***ÒµÓÐÏÞ¹«Ë¾</Gfmc>
                <Gfsh>913101***95811677F</Gfsh>
                <Gfyhzh>½¨ÐÐÉϺ£»ª³ØÂ·Ö§ÐÐ31001546***050004961</Gfyhzh>
                <Gfdzdh>ÉϺ£ÊвÜÑî·1***ºÅAÇø10ºÅ 021-62***662</Gfdzdh>
                <Xfmc>µ¤¶«******ÓÐÏÞ¹«Ë¾</Xfmc>
                <Xfsh>9121***826612142928</Xfsh>
                <Xfyhzh>ÖйúÅ©ÒµÒøÐÐ***Ö§ÐÐ 50590***0003583</Xfyhzh>
                <Xfdzdh>Áõ***´å  8922857</Xfdzdh>
                <Hjje>94847.03</Hjje>
                <Hjse>8536.23</Hjse>
                <Bz></Bz>
                <Kpr>ÓÚ*Ìï</Kpr>
                <Fhr>½¯*Ó¢</Fhr>
                <Skr>Âí*Ó¨</Skr>
                <Spbmbbh>39.0</Spbmbbh>
                <Hsbz>0</Hsbz>
                <Spxx>
                    <Sph>
                        <Xh>1</Xh>
                        <Spmc>*Èâ****¶³¼¦ÅÅÍÈ</Spmc>
                        <Ggxh></Ggxh>
                        <Jldw>kg</Jldw>
                        <Spbm>1030107010100000000</Spbm>
                        <Qyspbm>00005</Qyspbm>
                        <Syyhzcbz>0</Syyhzcbz>
                        <Lslbz></Lslbz>
                        <Yhzcsm></Yhzcsm>
                        <Dj>11.743119266055046</Dj>
                        <Sl>169.2</Sl>
                        <Je>1986.94</Je>
                        <Slv>0.09</Slv>
                        <Se>178.82</Se>
                    </Sph>
                    <Sph>
                        <Xh>2</Xh>
                        <Spmc>*Èâ****¶³¼¦ÅÅÍÈ</Spmc>
                        <Ggxh></Ggxh>
                        <Jldw>kg</Jldw>
                        <Spbm>1030107010100000000</Spbm>
                        <Qyspbm>00005</Qyspbm>
                        <Syyhzcbz>0</Syyhzcbz>
                        <Lslbz></Lslbz>
                        <Yhzcsm></Yhzcsm>
                        <Dj>11.467889908256881</Dj>
                        <Sl>385.4</Sl>
                        <Je>4419.72</Je>
                        <Slv>0.09</Slv>
                        <Se>397.78</Se>
                    </Sph>
                    <Sph>
                        <Xh>3</Xh>
                        <Spmc>*Èâ****¶³¼¦ÅÅÍÈ</Spmc>
                        <Ggxh></Ggxh>
                        <Jldw>kg</Jldw>
                        <Spbm>1030107010100000000</Spbm>
                        <Qyspbm>00021</Qyspbm>
                        <Syyhzcbz>0</Syyhzcbz>
                        <Lslbz></Lslbz>
                        <Yhzcsm></Yhzcsm>
                        <Dj>10.550458715596330</Dj>
                        <Sl>500</Sl>
                        <Je>5275.23</Je>
                        <Slv>0.09</Slv>
                        <Se>474.77</Se>
                    </Sph>
                    <Sph>
                        <Xh>4</Xh>
                        <Spmc>*Èâ****¶³¼¦ÅÅÍÈ</Spmc>
                        <Ggxh></Ggxh>
                        <Jldw>kg</Jldw>
                        <Spbm>1030107010100000000</Spbm>
                        <Qyspbm>00015</Qyspbm>
                        <Syyhzcbz>0</Syyhzcbz>
                        <Lslbz></Lslbz>
                        <Yhzcsm></Yhzcsm>
                        <Dj>33.944954128440367</Dj>
                        <Sl>2450</Sl>
                        <Je>83165.14</Je>
                        <Slv>0.09</Slv>
                        <Se>7484.86</Se>
                    </Sph>
                </Spxx>
            </Fp>
            <Fp>
                <Djh></Djh>
                <Fpzl>ÆÕͨ·¢Æ±</Fpzl>
                <Lbdm>0210***00404</Lbdm>
                <Fphm>47***608</Fphm>
                <Kprq>20***802</Kprq>
                <Gfmc>ÉϺ£***ʳƷÓÐÏÞ¹«Ë¾</Gfmc>
                <Gfsh>9131011***1334373K</Gfsh>
                <Gfyhzh>¹¤ÉÌÒøÐÐÉϺ£ÊÐÌìɽ·֧ÐÐ  10012469***06906246</Gfyhzh>
                <Gfdzdh>ÉϺ£ÊÐÆÕÍÓÇø½»Í¨Â·4***Ū4ºÅ18Â¥  52***0300</Gfdzdh>
                <Xfmc>µ¤¶«***ÓÐÏÞ¹«Ë¾</Xfmc>
                <Xfsh>91210******12142928</Xfsh>
                <Xfyhzh>ÖйúÅ©ÒµÒøÐÐ***Ö§ÐÐ 50590***0003583</Xfyhzh>
                <Xfdzdh>Áõ***´å  8922857</Xfdzdh>
                <Hjje>87590.64</Hjje>
                <Hjse>7883.16</Hjse>
                <Bz></Bz>
                <Kpr>ÓÚ*Ìï</Kpr>
                <Fhr>½¯*Ó¢</Fhr>
                <Skr>Âí*Ó¨</Skr>
                <Spbmbbh>39.0</Spbmbbh>
                <Hsbz>0</Hsbz>
                <Spxx>
                    <Sph>
                        <Xh>1</Xh>
                        <Spmc>*Èâ***¶³¼¦´óÐØ</Spmc>
                        <Ggxh></Ggxh>
                        <Jldw>kg</Jldw>
                        <Spbm>1030107010100000000</Spbm>
                        <Qyspbm>00002</Qyspbm>
                        <Syyhzcbz>0</Syyhzcbz>
                        <Lslbz></Lslbz>
                        <Yhzcsm></Yhzcsm>
                        <Dj>10.642201834862385</Dj>
                        <Sl>8230.5</Sl>
                        <Je>87590.64</Je>
                        <Slv>0.09</Slv>
                        <Se>7883.16</Se>
                    </Sph>
                </Spxx>
            </Fp>
        </Fpsj>
    </Fpxx>
</Kp>