summaryrefslogtreecommitdiffstats
path: root/sc/qa/uitest/csv_dialog/tdf92503.py
blob: 9774b03c35e3b05aa7364502e769c8ea083150c3 (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
# -*- 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, select_by_text
from libreoffice.uno.propertyvalue import mkPropertyValues
from libreoffice.calc.document import get_cell_by_position
from libreoffice.calc.csv_dialog import load_csv_file

class Tdf92503(UITestCase):

    def test_tdf92503(self):
        with load_csv_file(self, "tdf92503.csv", True) as xDialog:
            xFixedWidth = xDialog.getChild("tofixedwidth")
            xGrid = xDialog.getChild("csvgrid")
            xColumnType = xDialog.getChild("columntype")

            xFixedWidth.executeAction("CLICK", tuple())
            self.assertEqual('true', get_state_as_dict(xFixedWidth)['Checked'])

            # Use the right arrow to put the focus in the grid
            xGrid.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"}))

            self.assertEqual('true', get_state_as_dict(xColumnType)['Enabled'])

            select_by_text(xColumnType, "Date (DMY)")

            self.assertEqual('Date (DMY)', get_state_as_dict(xColumnType)['SelectEntryText'])

        document = self.ui_test.get_component()

        self.assertEqual("03/31/13 01:00 AM", get_cell_by_position(document, 0, 0, 0).getString())

        # Without the fix in place, this test would have failed with
        # AssertionError: '03/31/13 02:00 AM' != '31 Mar 2013, 02:00'
        self.assertEqual("03/31/13 02:00 AM", get_cell_by_position(document, 0, 0, 1).getString())
        self.assertEqual("03/31/13 03:00 AM", get_cell_by_position(document, 0, 0, 2).getString())
        self.assertEqual("03/30/14 01:00 AM", get_cell_by_position(document, 0, 0, 3).getString())
        self.assertEqual("03/30/14 02:00 AM", get_cell_by_position(document, 0, 0, 4).getString())
        self.assertEqual("03/30/14 03:00 AM", get_cell_by_position(document, 0, 0, 5).getString())
        self.assertEqual("03/29/15 01:00 AM", get_cell_by_position(document, 0, 0, 6).getString())
        self.assertEqual("03/29/15 02:00 AM", get_cell_by_position(document, 0, 0, 7).getString())
        self.assertEqual("03/29/15 03:00 AM", get_cell_by_position(document, 0, 0, 8).getString())

        self.ui_test.close_doc()

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