[Libreoffice-commits] core.git: 2 commits - dbaccess/Module_dbaccess.mk dbaccess/PythonTest_dbaccess_python.mk dbaccess/qa unotest/source writerfilter/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Tue Oct 7 07:17:24 PDT 2014
dbaccess/Module_dbaccess.mk | 6 +
dbaccess/PythonTest_dbaccess_python.mk | 20 ++++++
dbaccess/qa/extras/testdocuments/fdo84315.odb |binary
dbaccess/qa/python/fdo84315.py | 71 ++++++++++++++++++++++
unotest/source/python/org/libreoffice/unotest.py | 25 +++++++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 -
6 files changed, 125 insertions(+), 1 deletion(-)
New commits:
commit 6dbb6275ebd1a4299099c3b6bc82ec4ee0e1fb86
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Tue Sep 30 15:25:42 2014 +0200
fdo84315: add integration test for basic LibreOffice Base functionality
Thanks to Stephan for helping with the test environment setup:
sbergman at redhat.com: Do the same "set UserInstallation to user profile dir in
test/user-template" in UnoInProcess's setUp as is done in
test::BootstrapFixtureBase::setUp (unotest/source/cpp/bootstrapfixturebase.cxx)
for CppunitTests. That way, these tests all use the workdir/unittest/
UserInstallation concurrently, but they at least do not run into the gotcha in
SubstitutePathVariables::SetPredefinedPathVariables
(framework/source/services/substitutepathvars.cxx) to only set the
PREDEFVAR_USERPATH if PATH_EXISTS.
Change-Id: Iad058098a4c69cb567e2d3222af3c7d4ba993271
diff --git a/dbaccess/Module_dbaccess.mk b/dbaccess/Module_dbaccess.mk
index bbe3009..2dccdf8 100644
--- a/dbaccess/Module_dbaccess.mk
+++ b/dbaccess/Module_dbaccess.mk
@@ -68,6 +68,12 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,dbaccess,\
JunitTest_dbaccess_unoapi \
))
+ifneq ($(DISABLE_PYTHON),TRUE)
+$(eval $(call gb_Module_add_subsequentcheck_targets,dbaccess,\
+ PythonTest_dbaccess_python \
+))
+endif
+
endif
# vim: set noet sw=4 ts=4:
diff --git a/dbaccess/PythonTest_dbaccess_python.mk b/dbaccess/PythonTest_dbaccess_python.mk
new file mode 100644
index 0000000..7954cbc
--- /dev/null
+++ b/dbaccess/PythonTest_dbaccess_python.mk
@@ -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_PythonTest_PythonTest,dbaccess_python))
+
+$(eval $(call gb_PythonTest_set_defs,dbaccess_python,\
+ TDOC="$(SRCDIR)/dbaccess/qa/extras/testdocuments" \
+))
+
+$(eval $(call gb_PythonTest_add_modules,dbaccess_python,$(SRCDIR)/dbaccess/qa/python,\
+ fdo84315 \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/dbaccess/qa/extras/testdocuments/fdo84315.odb b/dbaccess/qa/extras/testdocuments/fdo84315.odb
new file mode 100644
index 0000000..0513ff5
Binary files /dev/null and b/dbaccess/qa/extras/testdocuments/fdo84315.odb differ
diff --git a/dbaccess/qa/python/fdo84315.py b/dbaccess/qa/python/fdo84315.py
new file mode 100644
index 0000000..0670f66
--- /dev/null
+++ b/dbaccess/qa/python/fdo84315.py
@@ -0,0 +1,71 @@
+#! /usr/bin/env python
+#
+# 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/.
+#
+
+import unittest
+from collections import deque
+from org.libreoffice.unotest import UnoInProcess
+
+class Fdo84315(unittest.TestCase):
+ _uno = None
+ _xDoc = None
+
+ @classmethod
+ def setUpClass(cls):
+ cls._uno = UnoInProcess()
+ cls._uno.setUp()
+ cls._xDoc = cls._uno.openBaseDoc('fdo84315.odb')
+
+ @classmethod
+ def tearDownClass(cls):
+ cls._uno.tearDown()
+
+ def test_fdo84315(self):
+ xDoc = self.__class__._xDoc
+ xDataSource = xDoc.DataSource
+ xCon = xDataSource.getConnection('','')
+ xStatement = xCon.createStatement()
+
+ xResultset = xStatement.executeQuery('SELECT "count" FROM "test_table"')
+ expected_values = deque([42, 4711])
+ self.assertTrue(xResultset)
+ xMeta = xResultset.MetaData
+ self.assertEqual(xMeta.ColumnCount, 1)
+ self.assertEqual(xResultset.findColumn("count"), 1)
+ self.assertEqual(xMeta.getColumnName(1), "count");
+ self.assertEqual(xMeta.getColumnType(1), 2); # numeric
+ while xResultset.next():
+ self.assertEqual(xResultset.getInt(1), expected_values.popleft())
+ self.assertEqual(len(expected_values), 0)
+
+ xResultset = xStatement.executeQuery('SELECT "name" FROM "test_table"')
+ expected_values = deque(['foo', 'bar'])
+ self.assertTrue(xResultset)
+ xMeta = xResultset.MetaData
+ self.assertEqual(xMeta.ColumnCount, 1)
+ self.assertEqual(xResultset.findColumn("name"), 1)
+ self.assertEqual(xMeta.getColumnName(1), "name");
+ self.assertEqual(xMeta.getColumnType(1), 12); # varchar
+ while xResultset.next():
+ self.assertEqual(xResultset.getString(1), expected_values.popleft())
+ self.assertEqual(len(expected_values), 0)
+
+ xResultset = xStatement.executeQuery('SELECT "id" FROM "test_table"')
+ expected_values = deque([0, 1])
+ self.assertTrue(xResultset)
+ xMeta = xResultset.MetaData
+ self.assertEqual(xMeta.ColumnCount, 1)
+ self.assertEqual(xResultset.findColumn("id"), 1)
+ self.assertEqual(xMeta.getColumnName(1), "id");
+ self.assertEqual(xMeta.getColumnType(1), 4); # integer
+ while xResultset.next():
+ self.assertEqual(xResultset.getInt(1), expected_values.popleft())
+ self.assertEqual(len(expected_values), 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/unotest/source/python/org/libreoffice/unotest.py b/unotest/source/python/org/libreoffice/unotest.py
index 6a7f814..1991b79 100644
--- a/unotest/source/python/org/libreoffice/unotest.py
+++ b/unotest/source/python/org/libreoffice/unotest.py
@@ -174,6 +174,15 @@ class UnoInProcess:
def getDoc(self):
return self.xDoc
def setUp(self):
+ # set UserInstallation to user profile dir in test/user-template:
+ path = os.getenv("WORKDIR")
+ if os.name == "nt":
+ # do not quote drive letter - it must be "X:"
+ url = "file:///" + path
+ else:
+ url = "file://" + quote(path)
+ os.putenv("UserInstallation", url + "/unittest")
+
self.xContext = pyuno.getComponentContext()
pyuno.private_initTestEnvironment()
def openEmptyWriterDoc(self):
@@ -202,6 +211,22 @@ class UnoInProcess:
assert(self.xDoc)
return self.xDoc
+ def openBaseDoc(self, file):
+ assert(self.xContext)
+ smgr = self.getContext().ServiceManager
+ desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.getContext())
+ props = [("Hidden", True), ("ReadOnly", False), ("AsTemplate", False)]
+ loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
+ path = os.getenv("TDOC")
+ if os.name == "nt":
+ #do not quote drive letter - it must be "X:"
+ url = "file:///" + path + "/" + quote(file)
+ else:
+ url = "file://" + quote(path) + "/" + quote(file)
+ self.xDoc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps)
+ assert(self.xDoc)
+ return self.xDoc
+
def checkProperties(self, obj, dict, test):
for k,v in dict.items():
obj.setPropertyValue(k, v)
commit 45b876555073990a490bf2c9e174bce803f12eea
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Tue Oct 7 15:58:16 2014 +0200
fix nullptr/boost compile error
error: no match for ternary âoperator?:â in
â((writerfilter::dmapper::DomainMapper_Impl*)this)->writerfilter::dmapper::DomainMapper_Impl::m_aFieldStack.std::stack<_Tp,
_Sequence>::empty<boost::shared_ptr<writerfilter::dmapper::FieldContext>,
std::deque<boost::shared_ptr<writerfilter::dmapper::FieldContext>,
std::allocator<boost::shared_ptr<writerfilter::dmapper::FieldContext> > > >() ?
nullptr :
((writerfilter::dmapper::DomainMapper_Impl*)this)->writerfilter::dmapper::DomainMapper_Impl::m_aFieldStack.std::stack<_Tp,
_Sequence>::top<boost::shared_ptr<writerfilter::dmapper::FieldContext>,
std::deque<boost::shared_ptr<writerfilter::dmapper::FieldContext>,
std::allocator<boost::shared_ptr<writerfilter::dmapper::FieldContext> > > >()â
Change-Id: I76c7507390bcf80f6ca722c4eedfd65c9a46952f
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1f98d0c..b396866 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3361,7 +3361,9 @@ void DomainMapper_Impl::CloseFieldCommand()
dmapper_logger->element("closeFieldCommand");
#endif
- FieldContextPtr pContext = m_aFieldStack.empty() ? nullptr : m_aFieldStack.top();
+ FieldContextPtr pContext;
+ if(!m_aFieldStack.empty())
+ pContext = m_aFieldStack.top();
OSL_ENSURE( pContext.get(), "no field context available");
if( pContext.get() )
{
More information about the Libreoffice-commits
mailing list