[Libreoffice-commits] core.git: sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Mon Jun 8 03:02:42 PDT 2015
sw/qa/extras/uiwriter/data/calc-data-source.ods |binary
sw/qa/extras/uiwriter/data/embedded-data-source.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 34 ++++++++++++++++++++
3 files changed, 34 insertions(+)
New commits:
commit df726c8b3e80bf2e1696f901ea01f192dcb8a77e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jun 8 11:33:36 2015 +0200
CppunitTest_sw_uiwriter: add embedded data source definition testcase
Fails with the last hunk of commit
4101949b2a9fcf399a1fa10c2547f745a24f5a3d (dbaccess: set correct BaseURI
for vnd.sun.star.pkg:// URLs on load, 2015-06-08) reverted.
Change-Id: Ieeaec3b0f925de0d5cf54e08b998038434686b3d
diff --git a/sw/qa/extras/uiwriter/data/calc-data-source.ods b/sw/qa/extras/uiwriter/data/calc-data-source.ods
new file mode 100644
index 0000000..0dec1df
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/calc-data-source.ods differ
diff --git a/sw/qa/extras/uiwriter/data/embedded-data-source.odt b/sw/qa/extras/uiwriter/data/embedded-data-source.odt
new file mode 100644
index 0000000..2eb54c5
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/embedded-data-source.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 43aeb63..5741d37 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -49,6 +49,7 @@
#include <com/sun/star/util/SearchFlags.hpp>
#include "com/sun/star/util/SearchAlgorithms.hpp"
#include "com/sun/star/i18n/TransliterationModulesExtra.hpp"
+#include "com/sun/star/sdbcx/XTablesSupplier.hpp"
static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/";
@@ -93,6 +94,7 @@ public:
void testUndoCharAttribute();
void testTdf86639();
void testTdf90883TableBoxGetCoordinates();
+ void testEmbeddedDataSource();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -130,6 +132,7 @@ public:
CPPUNIT_TEST(testUndoCharAttribute);
CPPUNIT_TEST(testTdf86639);
CPPUNIT_TEST(testTdf90883TableBoxGetCoordinates);
+ CPPUNIT_TEST(testEmbeddedDataSource);
CPPUNIT_TEST_SUITE_END();
@@ -980,6 +983,37 @@ void SwUiWriterTest::testTdf90883TableBoxGetCoordinates()
CPPUNIT_ASSERT_EQUAL( 2, (int)pos.Y() );
}
+void SwUiWriterTest::testEmbeddedDataSource()
+{
+ // Initially no data source.
+ uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
+ uno::Reference<sdb::XDatabaseContext> xDatabaseContext = sdb::DatabaseContext::create(xComponentContext);
+ CPPUNIT_ASSERT(!xDatabaseContext->hasByName("calc-data-source"));
+
+ // Load: should have a component and a data source, too.
+ load(DATA_DIRECTORY, "embedded-data-source.odt");
+ CPPUNIT_ASSERT(mxComponent.is());
+ CPPUNIT_ASSERT(xDatabaseContext->hasByName("calc-data-source"));
+
+ // Data source has a table named Sheet1.
+ uno::Reference<sdbc::XDataSource> xDataSource(xDatabaseContext->getByName("calc-data-source"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xDataSource.is());
+ uno::Reference<sdbcx::XTablesSupplier> xConnection(xDataSource->getConnection("", ""), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xTables(xConnection->getTables(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xTables.is());
+ CPPUNIT_ASSERT(xTables->hasByName("Sheet1"));
+
+ // Reload: should still have a component and a data source, too.
+ reload("writer8", "embedded-data-source.odt");
+ CPPUNIT_ASSERT(mxComponent.is());
+ CPPUNIT_ASSERT(xDatabaseContext->hasByName("calc-data-source"));
+
+ // Close: should not have a data source anymore.
+ mxComponent->dispose();
+ mxComponent.clear();
+ CPPUNIT_ASSERT(!xDatabaseContext->hasByName("calc-data-source"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list