tdf#75509 Add a UITest
Change-Id: I523e49b6711944b68e99324385df6c9188c0cd6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193174 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
fcab3bd90b
commit
c7b3ea692f
@@ -89,6 +89,11 @@ $(eval $(call gb_Module_add_screenshot_targets,dbaccess,\
|
||||
))
|
||||
|
||||
endif
|
||||
|
||||
$(eval $(call gb_Module_add_uicheck_targets,dbaccess,\
|
||||
UITest_edit_field \
|
||||
))
|
||||
|
||||
endif
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#
|
||||
# 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/.
|
||||
#
|
||||
|
||||
$(eval $(call gb_UITest_UITest,edit_field))
|
||||
|
||||
$(eval $(call gb_UITest_add_modules,edit_field,$(SRCDIR)/dbaccess/qa/uitest,\
|
||||
edit_field/ \
|
||||
))
|
||||
|
||||
$(eval $(call gb_UITest_set_defs,edit_field, \
|
||||
TDOC="$(SRCDIR)/dbaccess/qa/uitest/data" \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
Binary file not shown.
@@ -0,0 +1,115 @@
|
||||
# -*- 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_url_for_data_file, get_state_as_dict
|
||||
|
||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||
|
||||
from com.sun.star.util import URL
|
||||
|
||||
#Bug 75509 - Incorrect display of digits in default Numeric formatting
|
||||
# of a field when language isn't English
|
||||
class tdf75509(UITestCase):
|
||||
def execute_for_frame(self, xFrame, command):
|
||||
url = URL()
|
||||
url.Complete = command
|
||||
xUrlTransformer = self.xContext.ServiceManager.createInstanceWithContext(
|
||||
"com.sun.star.util.URLTransformer", self.xContext)
|
||||
_, url = xUrlTransformer.parseStrict(url)
|
||||
|
||||
xDispatch = xFrame.queryDispatch(url, "", 0)
|
||||
xDispatch.dispatch(url, [])
|
||||
|
||||
def test_tdf75509(self):
|
||||
# The sample file is an HSQLDB database with a single table. Aside from the primary key, the
|
||||
# table has two numeric type fields each with 2 decimal places. One of them is called
|
||||
# “FrenchField” and is set to a French locale (ie, the decimal separator is “,”) and the
|
||||
# other is called “EnglishField” and is set to a US English locale.
|
||||
with self.ui_test.load_file(get_url_for_data_file("tdf75509.odb")) as document:
|
||||
xDbWindow = self.xUITest.getTopFocusWindow()
|
||||
|
||||
self.xUITest.executeCommand(".uno:DBViewTables")
|
||||
|
||||
# We just want to select the single table in the list of tables but it seems difficult
|
||||
# to get access to the treeview window for it because there are multiple treeviews in a
|
||||
# hierarchy of windows with no name. However AppController handles SelectAll and that
|
||||
# does the trick
|
||||
self.xUITest.executeCommand(".uno:SelectAll")
|
||||
|
||||
self.xUITest.executeCommand(".uno:DBTableEdit")
|
||||
|
||||
xTableWindow = self.xUITest.getTopFocusWindow()
|
||||
|
||||
xTableEditor = xTableWindow.getChild("DBTableEditor")
|
||||
|
||||
# Select the “FrenchField” row
|
||||
xTableEditor.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
|
||||
|
||||
# Type a value with the comma decimal separator into the default value field
|
||||
xDefaultValue = xTableWindow.getChild("DefaultValue")
|
||||
|
||||
xDefaultValue.executeAction("FOCUS", tuple())
|
||||
xDefaultValue.executeAction("SET", mkPropertyValues({"TEXT": "3,14"}))
|
||||
|
||||
# Focus something else so that the example text will get updated
|
||||
xTableEditor.executeAction("FOCUS", tuple())
|
||||
|
||||
# The example format should be updated to reflect the default value
|
||||
xFormatText = xTableWindow.getChild("FormatText")
|
||||
self.assertEqual(get_state_as_dict(xFormatText)["Text"], "3,14")
|
||||
|
||||
# Select the “EnglishField"
|
||||
xTableEditor.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
|
||||
|
||||
# Perform the same tests with the “.” decimal separator
|
||||
xDefaultValue.executeAction("FOCUS", tuple())
|
||||
xDefaultValue.executeAction("SET", mkPropertyValues({"TEXT": "2.72"}))
|
||||
xTableEditor.executeAction("FOCUS", tuple())
|
||||
self.assertEqual(get_state_as_dict(xFormatText)["Text"], "2.72")
|
||||
|
||||
# Save the table (ie, just the table, not the actual database file to disk)
|
||||
self.execute_for_frame(self.ui_test.get_desktop().getCurrentFrame(), ".uno:Save")
|
||||
|
||||
self.xUITest.executeCommand(".uno:DBTableOpen")
|
||||
|
||||
xTableWindow = self.xUITest.getTopFocusWindow()
|
||||
|
||||
# Focus the “FrenchField” input in the table
|
||||
xGrid = xTableWindow.getChild("DBGrid")
|
||||
xGrid.executeAction("FOCUS", tuple())
|
||||
xGrid.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
|
||||
|
||||
# It should have the default value with a comma separator
|
||||
xEdit = self.xUITest.getFocusWindow()
|
||||
self.assertEqual(get_state_as_dict(xEdit)["Text"], "3,14")
|
||||
|
||||
# Focus the “EnglishField” input in the table
|
||||
xGrid.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
|
||||
|
||||
# It should have the default value with a dot separator
|
||||
xEdit = self.xUITest.getFocusWindow()
|
||||
self.assertEqual(get_state_as_dict(xEdit)["Text"], "2.72")
|
||||
|
||||
# Modify the field so that the we can save the record
|
||||
xEdit.executeAction("SET", mkPropertyValues({"TEXT": "2.71"}))
|
||||
|
||||
self.execute_for_frame(self.ui_test.get_desktop().getCurrentFrame(),
|
||||
".uno:RecSave")
|
||||
|
||||
# Check that the default values actually entered the database
|
||||
xDbController = self.ui_test.get_desktop().getActiveFrame().getController()
|
||||
xConnection = xDbController.ActiveConnection
|
||||
xStatement = xConnection.createStatement()
|
||||
xResultSet = xStatement.executeQuery("SELECT \"FrenchField\", \"EnglishField\" "
|
||||
"FROM \"Table1\"")
|
||||
self.assertTrue(xResultSet.next())
|
||||
self.assertEqual(xResultSet.getString(1), "3.14")
|
||||
self.assertEqual(xResultSet.getString(2), "2.71")
|
||||
|
||||
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
||||
Reference in New Issue
Block a user