summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-06-08 11:33:36 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-06-08 12:02:13 +0200
commitdf726c8b3e80bf2e1696f901ea01f192dcb8a77e (patch)
treed2d0d24526482f23fbf7ddb33b7a706eb8dafd45 /sw
parent8074bc61c7d286c113fd65bfabd911cd32908489 (diff)
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
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data/calc-data-source.odsbin0 -> 16055 bytes
-rw-r--r--sw/qa/extras/uiwriter/data/embedded-data-source.odtbin0 -> 9554 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx34
3 files changed, 34 insertions, 0 deletions
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 000000000000..0dec1df7db40
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/calc-data-source.ods
Binary files 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 000000000000..2eb54c5fb4ce
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/embedded-data-source.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 43aeb6317661..5741d37a4b86 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();