summaryrefslogtreecommitdiffstats
path: root/sc/qa/uitest/csv_dialog/tdf114878.py
blob: 90fa00ed9587a2b8d68e3b63eeec3c9378cba0ed (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
# -*- 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 get_state_as_dict
from libreoffice.calc.document import get_cell_by_position
from libreoffice.calc.csv_dialog import load_csv_file

class Td114878(UITestCase):

    def test_tdf114878(self):

        # First import the file with 'Evaluate Formulas' unchecked
        with load_csv_file(self, "tdf114878.csv", True):
            # Without the fix in place, this test would have failed with
            # Could not find child with id: evaluateformulas
            pass

        document = self.ui_test.get_component()

        self.assertEqual("=-3+5", get_cell_by_position(document, 0, 0, 0).getString())
        self.assertEqual('=TRUE()', get_cell_by_position(document, 0, 0, 1).getString())
        self.assertEqual('=4*10', get_cell_by_position(document, 0, 0, 2).getString())
        self.assertEqual('=SUM(A1:A3)', get_cell_by_position(document, 0, 0, 3).getString())

        self.ui_test.close_doc()

        # Now import the file with 'Evaluate Formulas' checked
        with load_csv_file(self, "tdf114878.csv", True) as xDialog:
            xEvalutateFormulas = xDialog.getChild("evaluateformulas")
            xEvalutateFormulas.executeAction("CLICK", tuple())
            self.assertEqual('true', get_state_as_dict(xEvalutateFormulas)['Selected'])

        document = self.ui_test.get_component()

        self.assertEqual("2", get_cell_by_position(document, 0, 0, 0).getString())
        self.assertEqual('1', get_cell_by_position(document, 0, 0, 1).getString())
        self.assertEqual('40', get_cell_by_position(document, 0, 0, 2).getString())
        self.assertEqual('43', get_cell_by_position(document, 0, 0, 3).getString())

        self.ui_test.close_doc()

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