summaryrefslogtreecommitdiffstats
path: root/dbaccess/qa/extras
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/qa/extras')
-rw-r--r--dbaccess/qa/extras/dialog-save.cxx110
-rw-r--r--dbaccess/qa/extras/empty-stdlib-save.cxx122
-rw-r--r--dbaccess/qa/extras/hsql_schema_import.cxx232
-rw-r--r--dbaccess/qa/extras/macros-test.cxx53
-rw-r--r--dbaccess/qa/extras/nolib-save.cxx112
-rw-r--r--dbaccess/qa/extras/rowsetclones.cxx136
-rw-r--r--dbaccess/qa/extras/testdocuments/RowSetClones.odbbin0 -> 33734 bytes
-rw-r--r--dbaccess/qa/extras/testdocuments/fdo84315.odbbin0 -> 3592 bytes
-rw-r--r--dbaccess/qa/extras/testdocuments/testDialogSave.odbbin0 -> 34059 bytes
-rw-r--r--dbaccess/qa/extras/testdocuments/testdb.odbbin0 -> 3700 bytes
10 files changed, 765 insertions, 0 deletions
diff --git a/dbaccess/qa/extras/dialog-save.cxx b/dbaccess/qa/extras/dialog-save.cxx
new file mode 100644
index 000000000..a336a66e3
--- /dev/null
+++ b/dbaccess/qa/extras/dialog-save.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <sal/config.h>
+#include <test/unoapi_test.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+class DialogSaveTest : public UnoApiTest
+{
+public:
+ DialogSaveTest();
+
+ void test();
+
+ CPPUNIT_TEST_SUITE(DialogSaveTest);
+// Should we disable this test on MOX and WNT?
+// #if !defined(MACOSX) && !defined(_WIN32)
+ CPPUNIT_TEST(test);
+// #endif
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+
+DialogSaveTest::DialogSaveTest()
+ : UnoApiTest("/dbaccess/qa/extras/testdocuments")
+{
+}
+
+void DialogSaveTest::test()
+{
+ // UnoApiTest::setUp (via InitVCL) puts each test under a locked SolarMutex,
+ // but at least the below xDocCloseable->close call could lead to a deadlock
+ // then, and it looks like none of the code here requires the SolarMutex to
+ // be locked anyway:
+ SolarMutexReleaser rel;
+
+ const OUString sStandard("Standard");
+ const OUString aFileName(m_directories.getURLFromWorkdir("CppunitTest/testDialogSave.odb"));
+ {
+ uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName);
+ CPPUNIT_ASSERT(xComponent.is());
+ uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
+ uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW);
+ uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
+ CPPUNIT_ASSERT(xStorBasLib.is());
+ uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
+ uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
+ CPPUNIT_ASSERT(xStorDlgLib.is());
+ uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
+ xBasLib->loadLibrary(sStandard);
+ CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
+ // the whole point of this test is to test the "save" operation
+ // when the Basic library is loaded, but not the Dialog library
+ CPPUNIT_ASSERT(!xDlgLib->isLibraryLoaded(sStandard));
+
+ // make some change to enable a save
+ // uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSuppl(xComponent, UNO_QUERY_THROW);
+ // uno::Reference< document::XDocumentPropertiesSupplier > xDocProps(xDocPropSuppl->getDocumentProperties());
+ // CPPUNIT_ASSERT(xDocProps.is());
+ // xDocProps.setTitle(xDocProps.getTitle() + " suffix");
+ uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW);
+ xDocMod->setModified(true);
+
+ // now save; the code path to exercise in this test is the "store to same location"
+ // do *not* change to store(As|To|URL)!
+ xDocStorable->store();
+
+ // close
+ uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW);
+ xDocCloseable->close(false);
+
+ // All our uno::References are (should?) be invalid now -> let them go out of scope
+ }
+ {
+ uno::Sequence<uno::Any> args(1);
+ args[0] <<= aFileName;
+ Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW);
+ Reference< beans::XPropertySet > xPS(xHNA->getByHierarchicalName("Dialogs/Standard/Dialog1.xml"), UNO_QUERY_THROW);
+ sal_Int64 nSize = 0;
+ CPPUNIT_ASSERT(xPS->getPropertyValue("Size") >>= nSize);
+ CPPUNIT_ASSERT(nSize != 0);
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/extras/empty-stdlib-save.cxx b/dbaccess/qa/extras/empty-stdlib-save.cxx
new file mode 100644
index 000000000..cce32ed08
--- /dev/null
+++ b/dbaccess/qa/extras/empty-stdlib-save.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <sal/config.h>
+#include <test/unoapi_test.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+class DialogSaveTest : public UnoApiTest
+{
+public:
+ DialogSaveTest();
+
+ void test();
+
+ CPPUNIT_TEST_SUITE(DialogSaveTest);
+// Should we disable this test on MOX and WNT?
+// #if !defined(MACOSX) && !defined(_WIN32)
+ CPPUNIT_TEST(test);
+// #endif
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+
+DialogSaveTest::DialogSaveTest()
+ : UnoApiTest("/dbaccess/qa/extras/testdocuments")
+{
+}
+
+void DialogSaveTest::test()
+{
+ // UnoApiTest::setUp (via InitVCL) puts each test under a locked SolarMutex,
+ // but at least the below xDocCloseable->close call could lead to a deadlock
+ // then, and it looks like none of the code here requires the SolarMutex to
+ // be locked anyway:
+ SolarMutexReleaser rel;
+
+ const OUString sStandard("Standard");
+ const OUString aFileName(m_directories.getURLFromWorkdir("CppunitTest/testEmptyStdlibSave.odb"));
+ {
+ uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName);
+ CPPUNIT_ASSERT(xComponent.is());
+ uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
+ uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW);
+ uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
+ CPPUNIT_ASSERT(xStorBasLib.is());
+ uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
+ uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
+ CPPUNIT_ASSERT(xStorDlgLib.is());
+ uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
+ xBasLib->loadLibrary(sStandard);
+ xDlgLib->loadLibrary(sStandard);
+ CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
+ CPPUNIT_ASSERT(xDlgLib->isLibraryLoaded(sStandard));
+
+ Any a;
+ uno::Reference< container::XNameContainer > xI;
+
+ a = xBasLib->getByName(sStandard);
+ a >>= xI;
+ CPPUNIT_ASSERT(xI.is());
+ xI->removeByName("Raralix");
+
+ a = xDlgLib->getByName(sStandard);
+ a >>= xI;
+ CPPUNIT_ASSERT(xI.is());
+ xI->removeByName("Dialog1");
+
+ // uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW);
+ // xDlgMod->setModified(sal_True);
+
+ // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW);
+ // xScrMod->setModified(sal_True);
+
+ // uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW);
+ // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
+ // xDocMod->setModified(sal_True);
+ // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
+ // CPPUNIT_ASSERT(xDocMod->isModified());
+
+ // now save; the code path to exercise in this test is the "store to same location"
+ // do *not* change to store(As|To|URL)!
+ xDocStorable->store();
+
+ // close
+ uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW);
+ xDocCloseable->close(false);
+
+ // All our uno::References are (should?) be invalid now -> let them go out of scope
+ }
+ {
+ uno::Sequence<uno::Any> args(1);
+ args[0] <<= aFileName;
+ Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Basic/Standard"));
+ CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Dialogs/Standard"));
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/extras/hsql_schema_import.cxx b/dbaccess/qa/extras/hsql_schema_import.cxx
new file mode 100644
index 000000000..89ee74ce0
--- /dev/null
+++ b/dbaccess/qa/extras/hsql_schema_import.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <fbcreateparser.hxx>
+#include <columndef.hxx>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace dbahsql;
+
+namespace
+{
+constexpr std::size_t operator"" _z(unsigned long long n) { return n; }
+
+const ColumnDefinition* lcl_findByType(const std::vector<ColumnDefinition>& columns,
+ sal_Int32 nType)
+{
+ for (const auto& column : columns)
+ {
+ if (column.getDataType() == nType)
+ return &column;
+ }
+ return nullptr;
+}
+}
+
+class HsqlSchemaImportTest : public CppUnit::TestFixture
+{
+public:
+ void testIntegerPrimaryKeyNotNull();
+ void testVarcharWithParam();
+ void testVarcharWithoutParam();
+ void testNumericWithTwoParam();
+ void testIntegerAutoincremental();
+ void testTimestampWithParam();
+ void testDefaultValueNow();
+ void testEvilNullColumnName();
+ // TODO testForeign, testDecomposer
+
+ CPPUNIT_TEST_SUITE(HsqlSchemaImportTest);
+
+ CPPUNIT_TEST(testIntegerPrimaryKeyNotNull);
+ CPPUNIT_TEST(testVarcharWithParam);
+ CPPUNIT_TEST(testVarcharWithoutParam);
+ CPPUNIT_TEST(testNumericWithTwoParam);
+ CPPUNIT_TEST(testIntegerAutoincremental);
+ CPPUNIT_TEST(testTimestampWithParam);
+ CPPUNIT_TEST(testDefaultValueNow);
+ CPPUNIT_TEST(testEvilNullColumnName);
+
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void HsqlSchemaImportTest::testIntegerPrimaryKeyNotNull()
+{
+ const OUString sql{ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY)" };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ CPPUNIT_ASSERT_EQUAL(OUString{ "\"myTable\"" }, aCreateParser.getTableName());
+ const auto& columns = aCreateParser.getColumnDef();
+ CPPUNIT_ASSERT_EQUAL(1_z, columns.size());
+ const auto& column = columns.at(0);
+ CPPUNIT_ASSERT_EQUAL(OUString{ "\"id\"" }, column.getName());
+ CPPUNIT_ASSERT_EQUAL(css::sdbc::DataType::INTEGER, column.getDataType());
+ CPPUNIT_ASSERT(column.isPrimaryKey());
+ CPPUNIT_ASSERT(!column.isNullable());
+ CPPUNIT_ASSERT(!column.isAutoIncremental());
+}
+
+void HsqlSchemaImportTest::testVarcharWithParam()
+{
+ const OUString sql{
+ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY, \"myText\" "
+ "VARCHAR(50))"
+ };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ CPPUNIT_ASSERT_EQUAL(2_z, columns.size());
+ const ColumnDefinition* colVarchar = lcl_findByType(columns, css::sdbc::DataType::VARCHAR);
+ CPPUNIT_ASSERT(colVarchar != nullptr);
+ const auto& params = colVarchar->getParams();
+ CPPUNIT_ASSERT_EQUAL(1_z, params.size());
+ constexpr sal_Int32 nParamExpected = 50;
+ CPPUNIT_ASSERT_EQUAL(nParamExpected, params.at(0)); // VARCHAR(50)
+}
+
+/**
+ * Special case:
+ * HSQLDB might define a column VARCHAR without parameter. With Firebird
+ * dialect, this is forbidden, so a default parameter has to be appended:
+ **/
+void HsqlSchemaImportTest::testVarcharWithoutParam()
+{
+ const OUString sql{
+ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY, \"myText\" "
+ "VARCHAR)"
+ };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ CPPUNIT_ASSERT_EQUAL(2_z, columns.size());
+ const ColumnDefinition* colVarchar = lcl_findByType(columns, css::sdbc::DataType::VARCHAR);
+ CPPUNIT_ASSERT(colVarchar != nullptr);
+ const auto& params = colVarchar->getParams();
+ CPPUNIT_ASSERT_EQUAL(1_z, params.size()); // parameter generated
+}
+
+void HsqlSchemaImportTest::testNumericWithTwoParam()
+{
+ const OUString sql{
+ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY, \"Betrag\" "
+ "NUMERIC(8,2))"
+ };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ CPPUNIT_ASSERT_EQUAL(2_z, columns.size());
+
+ const ColumnDefinition* colNumeric = lcl_findByType(columns, css::sdbc::DataType::NUMERIC);
+ CPPUNIT_ASSERT(colNumeric != nullptr);
+ const auto& params = colNumeric->getParams();
+ CPPUNIT_ASSERT_EQUAL(2_z, params.size());
+
+ constexpr sal_Int32 nPrecision = 8;
+ constexpr sal_Int32 nScale = 2;
+ CPPUNIT_ASSERT_EQUAL(nPrecision, params.at(0));
+ CPPUNIT_ASSERT_EQUAL(nScale, params.at(1));
+}
+
+void HsqlSchemaImportTest::testIntegerAutoincremental()
+{
+ const OUString sql{
+ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY GENERATED "
+ "BY DEFAULT AS IDENTITY(START WITH 0), \"myText\" VARCHAR(50))"
+ };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ const auto column = columns.at(0);
+ CPPUNIT_ASSERT_EQUAL(css::sdbc::DataType::INTEGER, column.getDataType());
+ CPPUNIT_ASSERT(column.isAutoIncremental());
+ CPPUNIT_ASSERT(column.isPrimaryKey());
+ CPPUNIT_ASSERT(!column.isNullable());
+}
+
+/**
+ * Special case:
+ * Hsqldb might use one parameter for defining column with type TIMESTAMP.
+ * With Firebird this is illegal.
+ */
+void HsqlSchemaImportTest::testTimestampWithParam()
+{
+ const OUString sql{
+ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY, \"myText\" "
+ "TIMESTAMP(0))"
+ };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ const ColumnDefinition* colTimeStamp = lcl_findByType(columns, css::sdbc::DataType::TIMESTAMP);
+
+ CPPUNIT_ASSERT(colTimeStamp != nullptr);
+
+ // instead of asserting parameter size, look at the deparsed string,
+ // because it's Firebird specific
+ OUString fbSql = aCreateParser.compose();
+ CPPUNIT_ASSERT(fbSql.indexOf("0") < 0); //does not contain
+}
+
+/**
+ * Special case:
+ * HSQLDB uses keyword NOW without quotes. Firebird uses single quotes 'NOW'
+ */
+void HsqlSchemaImportTest::testDefaultValueNow()
+{
+ const OUString sql{
+ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY, \"myDate\" "
+ "TIMESTAMP DEFAULT NOW)"
+ };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ const ColumnDefinition* colTimeStamp = lcl_findByType(columns, css::sdbc::DataType::TIMESTAMP);
+
+ CPPUNIT_ASSERT(colTimeStamp != nullptr);
+ CPPUNIT_ASSERT_EQUAL(OUString{ "NOW" }, colTimeStamp->getDefault()); // parsed NOW
+ OUString fbSql = aCreateParser.compose();
+ CPPUNIT_ASSERT(fbSql.indexOf("\'NOW\'") > 0); // composed 'NOW'
+}
+
+void HsqlSchemaImportTest::testEvilNullColumnName()
+{
+ const OUString sql{ "CREATE CACHED TABLE \"myTable\"(\"id\" INTEGER NOT NULL PRIMARY KEY, "
+ "\"myEvilNOT NULLName\" "
+ "VARCHAR(20))" };
+
+ FbCreateStmtParser aCreateParser;
+ aCreateParser.parse(sql);
+
+ const auto& columns = aCreateParser.getColumnDef();
+ CPPUNIT_ASSERT_EQUAL(2_z, columns.size());
+ const ColumnDefinition* colVarchar = lcl_findByType(columns, css::sdbc::DataType::VARCHAR);
+ CPPUNIT_ASSERT(colVarchar != nullptr);
+ CPPUNIT_ASSERT(colVarchar->isNullable());
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(HsqlSchemaImportTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/dbaccess/qa/extras/macros-test.cxx b/dbaccess/qa/extras/macros-test.cxx
new file mode 100644
index 000000000..d5b7538f9
--- /dev/null
+++ b/dbaccess/qa/extras/macros-test.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <sal/config.h>
+#include <test/unoapi_test.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#if !defined(MACOSX) && !defined(_WIN32)
+
+class DBAccessTest : public UnoApiTest
+{
+public:
+ DBAccessTest();
+
+ void test();
+
+ CPPUNIT_TEST_SUITE(DBAccessTest);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+
+DBAccessTest::DBAccessTest()
+ : UnoApiTest("/dbaccess/qa/extras/testdocuments")
+{
+}
+
+void DBAccessTest::test()
+{
+ const OUString aFileNameBase("testdb.odb");
+ OUString aFileName;
+ createFileURL(aFileNameBase, aFileName);
+ uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName);
+ CPPUNIT_ASSERT(xComponent.is());
+ xComponent->dispose();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(DBAccessTest);
+
+#endif
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/extras/nolib-save.cxx b/dbaccess/qa/extras/nolib-save.cxx
new file mode 100644
index 000000000..b42171ce2
--- /dev/null
+++ b/dbaccess/qa/extras/nolib-save.cxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <sal/config.h>
+#include <test/unoapi_test.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+class DialogSaveTest : public UnoApiTest
+{
+public:
+ DialogSaveTest();
+
+ void test();
+
+ CPPUNIT_TEST_SUITE(DialogSaveTest);
+// Should we disable this test on MOX and WNT?
+// #if !defined(MACOSX) && !defined(_WIN32)
+ CPPUNIT_TEST(test);
+// #endif
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+
+DialogSaveTest::DialogSaveTest()
+ : UnoApiTest("/dbaccess/qa/extras/testdocuments")
+{
+}
+
+void DialogSaveTest::test()
+{
+ // UnoApiTest::setUp (via InitVCL) puts each test under a locked SolarMutex,
+ // but at least the below xDocCloseable->close call could lead to a deadlock
+ // then, and it looks like none of the code here requires the SolarMutex to
+ // be locked anyway:
+ SolarMutexReleaser rel;
+
+ const OUString sStandard("Standard");
+ const OUString aFileName(m_directories.getURLFromWorkdir("CppunitTest/testNolibSave.odb"));
+ {
+ uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName);
+ CPPUNIT_ASSERT(xComponent.is());
+ uno::Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
+ uno::Reference< document::XEmbeddedScripts > xDocScr(xComponent, UNO_QUERY_THROW);
+ uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
+ CPPUNIT_ASSERT(xStorBasLib.is());
+ uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
+ uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
+ CPPUNIT_ASSERT(xStorDlgLib.is());
+ uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
+ xBasLib->loadLibrary(sStandard);
+ xDlgLib->loadLibrary(sStandard);
+ CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
+ CPPUNIT_ASSERT(xDlgLib->isLibraryLoaded(sStandard));
+
+ xBasLib->removeLibrary(sStandard);
+ xDlgLib->removeLibrary(sStandard);
+
+ // uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW);
+ // xDlgMod->setModified(sal_True);
+
+ // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW);
+ // xScrMod->setModified(sal_True);
+
+ // uno::Reference< util::XModifiable > xDocMod(xComponent, UNO_QUERY_THROW);
+ // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
+ // xDocMod->setModified(sal_True);
+ // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
+ // CPPUNIT_ASSERT(xDocMod->isModified());
+
+ // now save; the code path to exercise in this test is the "store to same location"
+ // do *not* change to store(As|To|URL)!
+ xDocStorable->store();
+
+ // close
+ uno::Reference< util::XCloseable > xDocCloseable(xComponent, UNO_QUERY_THROW);
+ xDocCloseable->close(false);
+
+ // All our uno::References are (should?) be invalid now -> let them go out of scope
+ }
+ {
+ uno::Sequence<uno::Any> args(1);
+ args[0] <<= aFileName;
+ Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments("com.sun.star.packages.Package", args), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Basic/Standard"));
+ CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName("Dialogs/Standard"));
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/extras/rowsetclones.cxx b/dbaccess/qa/extras/rowsetclones.cxx
new file mode 100644
index 000000000..f62314205
--- /dev/null
+++ b/dbaccess/qa/extras/rowsetclones.cxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <sal/config.h>
+#include <test/unoapi_test.hxx>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+
+class RowSetClones : public UnoApiTest
+{
+public:
+ RowSetClones();
+
+ void test();
+
+ CPPUNIT_TEST_SUITE(RowSetClones);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+
+RowSetClones::RowSetClones()
+ : UnoApiTest("")
+{
+}
+
+void RowSetClones::test()
+{
+ const OUString sFilePath(m_directories.getURLFromWorkdir("CppunitTest/RowSetClones.odb"));
+
+ uno::Reference< lang::XComponent > xComponent (loadFromDesktop(sFilePath));
+ CPPUNIT_ASSERT(xComponent.is());
+
+ uno::Reference< XOfficeDatabaseDocument > xDocument(xComponent, UNO_QUERY);
+ CPPUNIT_ASSERT(xDocument.is());
+
+ uno::Reference< XDataSource > xDataSource = xDocument->getDataSource();
+ CPPUNIT_ASSERT(xDataSource.is());
+
+ uno::Reference< XConnection > xConnection = xDataSource->getConnection("","");
+ CPPUNIT_ASSERT(xConnection.is());
+
+ uno::Reference< XRowSet > xRowSet (getMultiServiceFactory()->createInstance("com.sun.star.sdb.RowSet" ), UNO_QUERY);
+ CPPUNIT_ASSERT(xRowSet.is());
+ uno::Reference< XPropertySet > rowSetProperties ( xRowSet, UNO_QUERY );
+ CPPUNIT_ASSERT(rowSetProperties.is());
+ rowSetProperties->setPropertyValue("Command", Any(OUString("SELECT * FROM Assets ORDER BY AssetID")));
+ rowSetProperties->setPropertyValue("CommandType", Any(CommandType::COMMAND));
+ rowSetProperties->setPropertyValue("ActiveConnection", Any(xConnection));
+
+ xRowSet->execute();
+ uno::Reference< XResultSet > xResultSet = xRowSet;
+ CPPUNIT_ASSERT(xResultSet.is());
+ // always starts at BeforeFirst position
+ CPPUNIT_ASSERT(xResultSet->isBeforeFirst());
+ CPPUNIT_ASSERT(xResultSet->next());
+ CPPUNIT_ASSERT(xResultSet->isFirst());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xResultSet->getRow());
+
+ uno::Reference< XRow > xRow(xResultSet, UNO_QUERY);
+ CPPUNIT_ASSERT(xRow.is());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xRow->getInt(1));
+
+ uno::Reference< XResultSetAccess > xResultSetAccess(xResultSet, UNO_QUERY);
+ CPPUNIT_ASSERT(xResultSetAccess.is());
+ uno::Reference< XResultSet > xResultSetClone = xResultSetAccess->createResultSet();
+ CPPUNIT_ASSERT(xResultSetClone.is());
+
+ uno::Reference< XRow > xRowClone(xResultSetClone, UNO_QUERY);
+ CPPUNIT_ASSERT(xRowClone.is());
+
+ // the clone starts at same position as what it is cloned from,
+ // and does not move its source.
+ CPPUNIT_ASSERT(xResultSetClone->isFirst());
+ CPPUNIT_ASSERT(xResultSet->isFirst());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xResultSet->getRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xResultSetClone->getRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xRow->getInt(1));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xRowClone->getInt(1));
+
+ // if we move the source, the clone does not move
+ CPPUNIT_ASSERT(xResultSet->next());
+ CPPUNIT_ASSERT(xResultSetClone->isFirst());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xResultSet->getRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xResultSetClone->getRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xRow->getInt(1));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xRowClone->getInt(1));
+
+ CPPUNIT_ASSERT(xResultSet->last());
+ CPPUNIT_ASSERT(xResultSet->isLast());
+ CPPUNIT_ASSERT(xResultSetClone->isFirst());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xRowClone->getInt(1));
+
+ // and the other way round
+ CPPUNIT_ASSERT(xResultSet->first());
+ CPPUNIT_ASSERT(xResultSetClone->next());
+ CPPUNIT_ASSERT(xResultSet->isFirst());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xResultSetClone->getRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xRowClone->getInt(1));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xRow->getInt(1));
+
+ CPPUNIT_ASSERT(xResultSetClone->last());
+ CPPUNIT_ASSERT(xResultSetClone->isLast());
+ CPPUNIT_ASSERT(xResultSet->isFirst());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xRow->getInt(1));
+
+ closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(RowSetClones);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/qa/extras/testdocuments/RowSetClones.odb b/dbaccess/qa/extras/testdocuments/RowSetClones.odb
new file mode 100644
index 000000000..91ed328ac
--- /dev/null
+++ b/dbaccess/qa/extras/testdocuments/RowSetClones.odb
Binary files differ
diff --git a/dbaccess/qa/extras/testdocuments/fdo84315.odb b/dbaccess/qa/extras/testdocuments/fdo84315.odb
new file mode 100644
index 000000000..0513ff587
--- /dev/null
+++ b/dbaccess/qa/extras/testdocuments/fdo84315.odb
Binary files differ
diff --git a/dbaccess/qa/extras/testdocuments/testDialogSave.odb b/dbaccess/qa/extras/testdocuments/testDialogSave.odb
new file mode 100644
index 000000000..d72531253
--- /dev/null
+++ b/dbaccess/qa/extras/testdocuments/testDialogSave.odb
Binary files differ
diff --git a/dbaccess/qa/extras/testdocuments/testdb.odb b/dbaccess/qa/extras/testdocuments/testdb.odb
new file mode 100644
index 000000000..038e998e6
--- /dev/null
+++ b/dbaccess/qa/extras/testdocuments/testdb.odb
Binary files differ