dbaccess/CppunitTest_dbaccess_hsqlbinary_import.mk | 114 ---------- dbaccess/CppunitTest_dbaccess_migration.mk | 26 +- dbaccess/CppunitTest_dbaccess_tdf126268.mk | 118 ----------- dbaccess/Module_dbaccess.mk | 4 dbaccess/qa/unit/hsql_binary_import.cxx | 113 ---------- dbaccess/qa/unit/migration.cxx | 218 +++++++++++++++++++++ dbaccess/qa/unit/tdf119625.cxx | 121 ----------- dbaccess/qa/unit/tdf126268.cxx | 98 --------- sfx2/source/control/thumbnailviewitemacc.cxx | 4 sfx2/source/control/thumbnailviewitemacc.hxx | 1 10 files changed, 233 insertions(+), 584 deletions(-)
New commits: commit fbdfde26391730216bae230cd6f228a6ae6ee89c Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Feb 28 11:45:53 2025 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Feb 28 13:49:53 2025 +0100 CppunitTest_dbaccess_migration: Unify into 1 place and use setUp and tearDown to enable/disable the experimental mode Change-Id: I922bc289179528d1fc1df1a3545315ec92489afc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182355 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins diff --git a/dbaccess/CppunitTest_dbaccess_hsqlbinary_import.mk b/dbaccess/CppunitTest_dbaccess_hsqlbinary_import.mk deleted file mode 100644 index 23ec9e1e4e1e..000000000000 --- a/dbaccess/CppunitTest_dbaccess_hsqlbinary_import.mk +++ /dev/null @@ -1,114 +0,0 @@ -# -*- 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_CppunitTest_CppunitTest,dbaccess_hsql_binary_import)) - -$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_hsql_binary_import, \ - dbaccess/qa/unit/hsql_binary_import \ -)) - -$(eval $(call gb_CppunitTest_use_external,dbaccess_hsql_binary_import,boost_headers)) - -$(eval $(call gb_CppunitTest_use_libraries,dbaccess_hsql_binary_import, \ - basegfx \ - comphelper \ - cppu \ - cppuhelper \ - dba \ - dbahsql \ - dbu \ - sdbt \ - drawinglayer \ - editeng \ - for \ - forui \ - i18nlangtag \ - msfilter \ - oox \ - sal \ - salhelper \ - sax \ - sb \ - sfx \ - sot \ - svl \ - svt \ - svx \ - svxcore \ - test \ - subsequenttest \ - tl \ - tk \ - ucbhelper \ - unotest \ - utl \ - $(call gb_Helper_optional,SCRIPTING, \ - vbahelper) \ - vcl \ - xo \ -)) - -$(eval $(call gb_CppunitTest_use_ure,dbaccess_hsql_binary_import)) -$(eval $(call gb_CppunitTest_use_vcl,dbaccess_hsql_binary_import)) - -$(eval $(call gb_CppunitTest_set_include,dbaccess_hsql_binary_import,\ - -I$(SRCDIR)/dbaccess/source/filter/hsqldb \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_CppunitTest_use_custom_headers,dbaccess_hsql_binary_import,\ - officecfg/registry \ -)) - -$(eval $(call gb_CppunitTest_use_api,dbaccess_hsql_binary_import,\ - offapi \ - oovbaapi \ - udkapi \ -)) - -$(eval $(call gb_CppunitTest_use_components,dbaccess_hsql_binary_import,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - connectivity/source/drivers/hsqldb/hsqldb \ - $(if $(ENABLE_FIREBIRD_SDBC),connectivity/source/drivers/firebird/firebird_sdbc) \ - connectivity/source/manager/sdbc2 \ - dbaccess/util/dba \ - dbaccess/util/dbu \ - dbaccess/util/sdbt \ - dbaccess/source/filter/xml/dbaxml \ - filter/source/config/cache/filterconfig1 \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - linguistic/source/lng \ - oox/util/oox \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - scripting/source/basprov/basprov \ - scripting/util/scriptframe \ - sfx2/util/sfx \ - sot/util/sot \ - svl/source/fsstor/fsstorage \ - svl/util/svl \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ - uui/util/uui \ - xmloff/util/xo \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,dbaccess_hsql_binary_import)) - -# vim: set noet sw=4 ts=4: diff --git a/dbaccess/CppunitTest_dbaccess_tdf119625.mk b/dbaccess/CppunitTest_dbaccess_migration.mk similarity index 70% rename from dbaccess/CppunitTest_dbaccess_tdf119625.mk rename to dbaccess/CppunitTest_dbaccess_migration.mk index b96ea797f27f..89ff0f05d4e1 100644 --- a/dbaccess/CppunitTest_dbaccess_tdf119625.mk +++ b/dbaccess/CppunitTest_dbaccess_migration.mk @@ -7,15 +7,15 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -$(eval $(call gb_CppunitTest_CppunitTest,dbaccess_tdf119625)) +$(eval $(call gb_CppunitTest_CppunitTest,dbaccess_migration)) -$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_tdf119625, \ - dbaccess/qa/unit/tdf119625 \ +$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_migration, \ + dbaccess/qa/unit/migration \ )) -$(eval $(call gb_CppunitTest_use_external,dbaccess_tdf119625,boost_headers)) +$(eval $(call gb_CppunitTest_use_external,dbaccess_migration,boost_headers)) -$(eval $(call gb_CppunitTest_use_libraries,dbaccess_tdf119625, \ +$(eval $(call gb_CppunitTest_use_libraries,dbaccess_migration, \ basegfx \ comphelper \ cppu \ @@ -54,30 +54,30 @@ $(eval $(call gb_CppunitTest_use_libraries,dbaccess_tdf119625, \ xo \ )) -$(eval $(call gb_CppunitTest_use_ure,dbaccess_tdf119625)) -$(eval $(call gb_CppunitTest_use_vcl,dbaccess_tdf119625)) +$(eval $(call gb_CppunitTest_use_ure,dbaccess_migration)) +$(eval $(call gb_CppunitTest_use_vcl,dbaccess_migration)) -$(eval $(call gb_CppunitTest_set_include,dbaccess_tdf119625,\ +$(eval $(call gb_CppunitTest_set_include,dbaccess_migration,\ -I$(SRCDIR)/dbaccess/source/filter/hsqldb \ $$(INCLUDE) \ )) -$(eval $(call gb_CppunitTest_use_custom_headers,dbaccess_tdf119625,\ +$(eval $(call gb_CppunitTest_use_custom_headers,dbaccess_migration,\ officecfg/registry \ )) -$(eval $(call gb_CppunitTest_use_api,dbaccess_tdf119625,\ +$(eval $(call gb_CppunitTest_use_api,dbaccess_migration,\ offapi \ oovbaapi \ udkapi \ )) -$(eval $(call gb_CppunitTest_use_components,dbaccess_tdf119625,\ +$(eval $(call gb_CppunitTest_use_components,dbaccess_migration,\ basic/util/sb \ comphelper/util/comphelp \ configmgr/source/configmgr \ connectivity/source/drivers/hsqldb/hsqldb \ - connectivity/source/drivers/firebird/firebird_sdbc \ + $(if $(ENABLE_FIREBIRD_SDBC),connectivity/source/drivers/firebird/firebird_sdbc) \ connectivity/source/manager/sdbc2 \ dbaccess/util/dba \ dbaccess/util/dbu \ @@ -109,6 +109,6 @@ $(eval $(call gb_CppunitTest_use_components,dbaccess_tdf119625,\ xmloff/util/xo \ )) -$(eval $(call gb_CppunitTest_use_configuration,dbaccess_tdf119625)) +$(eval $(call gb_CppunitTest_use_configuration,dbaccess_migration)) # vim: set noet sw=4 ts=4: diff --git a/dbaccess/CppunitTest_dbaccess_tdf126268.mk b/dbaccess/CppunitTest_dbaccess_tdf126268.mk deleted file mode 100644 index e2f6df6aeab9..000000000000 --- a/dbaccess/CppunitTest_dbaccess_tdf126268.mk +++ /dev/null @@ -1,118 +0,0 @@ -# -*- 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_CppunitTest_CppunitTest,dbaccess_tdf126268)) - -$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_tdf126268, \ - dbaccess/qa/unit/tdf126268 \ -)) - -$(eval $(call gb_CppunitTest_use_external,dbaccess_tdf126268,boost_headers)) - -$(eval $(call gb_CppunitTest_use_libraries,dbaccess_tdf126268, \ - basegfx \ - comphelper \ - cppu \ - cppuhelper \ - dba \ - dbahsql \ - dbu \ - sdbt \ - drawinglayer \ - editeng \ - for \ - forui \ - i18nlangtag \ - msfilter \ - oox \ - sal \ - salhelper \ - sax \ - sb \ - sfx \ - sot \ - svl \ - svt \ - svx \ - svxcore \ - test \ - subsequenttest \ - tl \ - tk \ - ucbhelper \ - unotest \ - utl \ - $(call gb_Helper_optional,SCRIPTING, \ - vbahelper) \ - vcl \ - xo \ -)) - -$(eval $(call gb_CppunitTest_use_ure,dbaccess_tdf126268)) -$(eval $(call gb_CppunitTest_use_vcl,dbaccess_tdf126268)) - -$(eval $(call gb_CppunitTest_set_include,dbaccess_tdf126268,\ - -I$(SRCDIR)/dbaccess/source/filter/hsqldb \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_CppunitTest_use_custom_headers,dbaccess_tdf126268,\ - officecfg/registry \ -)) - -$(eval $(call gb_CppunitTest_use_api,dbaccess_tdf126268,\ - offapi \ - oovbaapi \ - udkapi \ -)) - -$(eval $(call gb_CppunitTest_use_components,dbaccess_tdf126268,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - connectivity/source/drivers/hsqldb/hsqldb \ - connectivity/source/drivers/firebird/firebird_sdbc \ - connectivity/source/manager/sdbc2 \ - dbaccess/util/dba \ - dbaccess/util/dbu \ - dbaccess/util/sdbt \ - dbaccess/source/filter/xml/dbaxml \ - filter/source/config/cache/filterconfig1 \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - linguistic/source/lng \ - oox/util/oox \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - scripting/source/basprov/basprov \ - scripting/util/scriptframe \ - sfx2/util/sfx \ - sot/util/sot \ - svl/source/fsstor/fsstorage \ - svl/util/svl \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ - uui/util/uui \ - xmloff/util/xo \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,dbaccess_tdf126268)) - -$(eval $(call gb_CppunitTest_use_uiconfigs,dbaccess_tdf126268, \ - dbaccess \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/dbaccess/Module_dbaccess.mk b/dbaccess/Module_dbaccess.mk index 64c92b0d2dc8..f368fcc33e19 100644 --- a/dbaccess/Module_dbaccess.mk +++ b/dbaccess/Module_dbaccess.mk @@ -37,9 +37,7 @@ $(eval $(call gb_Module_add_targets,dbaccess,\ ifneq ($(OS),iOS) ifeq ($(ENABLE_FIREBIRD_SDBC),TRUE) $(eval $(call gb_Module_add_check_targets,dbaccess,\ - $(if $(ENABLE_JAVA),CppunitTest_dbaccess_hsqlbinary_import) \ - $(if $(ENABLE_JAVA),CppunitTest_dbaccess_tdf119625) \ - $(if $(ENABLE_JAVA),CppunitTest_dbaccess_tdf126268) \ + $(if $(ENABLE_JAVA),CppunitTest_dbaccess_migration) \ )) $(eval $(call gb_Module_add_check_targets,dbaccess,\ diff --git a/dbaccess/qa/unit/hsql_binary_import.cxx b/dbaccess/qa/unit/hsql_binary_import.cxx deleted file mode 100644 index 4a0f6dd525b6..000000000000 --- a/dbaccess/qa/unit/hsql_binary_import.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- 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 "dbtest_base.cxx" - -#include <osl/process.h> -#include <cppunit/plugin/TestPlugIn.h> -#include <com/sun/star/sdbc/XRow.hpp> -#include <cppunit/extensions/HelperMacros.h> -#include <officecfg/Office/Common.hxx> - -class HsqlBinaryImportTest : public DBTestBase -{ -public: - void testBinaryImport(); - - virtual void setUp() override; - - CPPUNIT_TEST_SUITE(HsqlBinaryImportTest); - - CPPUNIT_TEST(testBinaryImport); - - CPPUNIT_TEST_SUITE_END(); -}; - -void HsqlBinaryImportTest::setUp() -{ - DBTestBase::setUp(); - osl_setEnvironment(u"DBACCESS_HSQL_MIGRATION"_ustr.pData, u"1"_ustr.pData); -} - -void HsqlBinaryImportTest::testBinaryImport() -{ - bool oldValue = officecfg::Office::Common::Misc::ExperimentalMode::get(); - { - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::ExperimentalMode::set(true, xChanges); - xChanges->commit(); - } - - // the migration requires the file to be writable - createTempCopy(u"hsqldb_migration_test.odb"); - uno::Reference<XOfficeDatabaseDocument> const xDocument - = getDocumentForUrl(maTempFile.GetURL()); - - uno::Reference<XConnection> xConnection = getConnectionForDocument(xDocument); - // at this point migration is already done - - uno::Reference<XStatement> statement = xConnection->createStatement(); - - uno::Reference<XResultSet> xRes - = statement->executeQuery(u"SELECT \"ID\", \"Power_value\", \"Power_name\", \"Retired\", " - "\"Birth_date\" FROM \"TestTable\" ORDER BY \"ID\""_ustr); - uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW); - - // assert first row - CPPUNIT_ASSERT(xRes->next()); - constexpr sal_Int16 idExpected = 1; - CPPUNIT_ASSERT_EQUAL(idExpected, xRow->getShort(1)); - CPPUNIT_ASSERT_EQUAL(u"45.32"_ustr, xRow->getString(2)); // numeric - CPPUNIT_ASSERT_EQUAL(u"laser eye"_ustr, xRow->getString(3)); // varchar - CPPUNIT_ASSERT(xRow->getBoolean(4)); // boolean - - css::util::Date date = xRow->getDate(5); - - CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 15 }, date.Day); - CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 1 }, date.Month); - CPPUNIT_ASSERT_EQUAL(sal_Int16{ 1996 }, date.Year); - - // assert second row - CPPUNIT_ASSERT(xRes->next()); - constexpr sal_Int16 secondIdExpected = 2; - CPPUNIT_ASSERT_EQUAL(secondIdExpected, xRow->getShort(1)); // ID - CPPUNIT_ASSERT_EQUAL(u"54.12"_ustr, xRow->getString(2)); // numeric - CPPUNIT_ASSERT_EQUAL(u"telekinesis"_ustr, xRow->getString(3)); // varchar - CPPUNIT_ASSERT(!xRow->getBoolean(4)); // boolean - - date = xRow->getDate(5); - CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 26 }, date.Day); - CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 2 }, date.Month); - CPPUNIT_ASSERT_EQUAL(sal_Int16{ 1998 }, date.Year); - - // assert third row - CPPUNIT_ASSERT(xRes->next()); - CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xRow->getShort(1)); // ID - CPPUNIT_ASSERT_EQUAL(u"12.00"_ustr, xRow->getString(2)); // numeric - CPPUNIT_ASSERT_EQUAL(u"mind-reading"_ustr, xRow->getString(3)); // varchar - CPPUNIT_ASSERT(xRow->getBoolean(4)); // boolean - - date = xRow->getDate(5); - CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 20 }, date.Day); - CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 5 }, date.Month); - CPPUNIT_ASSERT_EQUAL(sal_Int16{ 1967 }, date.Year); - - if (!oldValue) - { - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::ExperimentalMode::set(false, xChanges); - xChanges->commit(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(HsqlBinaryImportTest); - -CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/dbaccess/qa/unit/migration.cxx b/dbaccess/qa/unit/migration.cxx new file mode 100644 index 000000000000..491e36fe8562 --- /dev/null +++ b/dbaccess/qa/unit/migration.cxx @@ -0,0 +1,218 @@ +/* -*- 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 "dbtest_base.cxx" + +#include <osl/process.h> +#include <cppunit/plugin/TestPlugIn.h> +#include <com/sun/star/sdbc/XRow.hpp> +#include <cppunit/extensions/HelperMacros.h> +#include <officecfg/Office/Common.hxx> + +class MigrationTest : public DBTestBase +{ +public: + void testBinaryImport(); + void testNumbers(); + void testTime(); + + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(MigrationTest); + + CPPUNIT_TEST(testBinaryImport); + CPPUNIT_TEST(testNumbers); + CPPUNIT_TEST(testTime); + + CPPUNIT_TEST_SUITE_END(); +}; + +void MigrationTest::setUp() +{ + DBTestBase::setUp(); + osl_setEnvironment(u"DBACCESS_HSQL_MIGRATION"_ustr.pData, u"1"_ustr.pData); + + std::shared_ptr<comphelper::ConfigurationChanges> xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::ExperimentalMode::set(true, xChanges); + xChanges->commit(); +} + +void MigrationTest::tearDown() +{ + std::shared_ptr<comphelper::ConfigurationChanges> xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::ExperimentalMode::set(false, xChanges); + xChanges->commit(); + + DBTestBase::tearDown(); +} + +void MigrationTest::testBinaryImport() +{ + // the migration requires the file to be writable + createTempCopy(u"hsqldb_migration_test.odb"); + uno::Reference<XOfficeDatabaseDocument> const xDocument + = getDocumentForUrl(maTempFile.GetURL()); + + uno::Reference<XConnection> xConnection = getConnectionForDocument(xDocument); + // at this point migration is already done + + uno::Reference<XStatement> statement = xConnection->createStatement(); + + uno::Reference<XResultSet> xRes + = statement->executeQuery(u"SELECT \"ID\", \"Power_value\", \"Power_name\", \"Retired\", " + "\"Birth_date\" FROM \"TestTable\" ORDER BY \"ID\""_ustr); + uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW); + + // assert first row + CPPUNIT_ASSERT(xRes->next()); + constexpr sal_Int16 idExpected = 1; + CPPUNIT_ASSERT_EQUAL(idExpected, xRow->getShort(1)); + CPPUNIT_ASSERT_EQUAL(u"45.32"_ustr, xRow->getString(2)); // numeric + CPPUNIT_ASSERT_EQUAL(u"laser eye"_ustr, xRow->getString(3)); // varchar + CPPUNIT_ASSERT(xRow->getBoolean(4)); // boolean + + css::util::Date date = xRow->getDate(5); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 15 }, date.Day); + CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 1 }, date.Month); + CPPUNIT_ASSERT_EQUAL(sal_Int16{ 1996 }, date.Year); + + // assert second row + CPPUNIT_ASSERT(xRes->next()); + constexpr sal_Int16 secondIdExpected = 2; + CPPUNIT_ASSERT_EQUAL(secondIdExpected, xRow->getShort(1)); // ID + CPPUNIT_ASSERT_EQUAL(u"54.12"_ustr, xRow->getString(2)); // numeric + CPPUNIT_ASSERT_EQUAL(u"telekinesis"_ustr, xRow->getString(3)); // varchar + CPPUNIT_ASSERT(!xRow->getBoolean(4)); // boolean + + date = xRow->getDate(5); + CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 26 }, date.Day); + CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 2 }, date.Month); + CPPUNIT_ASSERT_EQUAL(sal_Int16{ 1998 }, date.Year); + + // assert third row + CPPUNIT_ASSERT(xRes->next()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xRow->getShort(1)); // ID + CPPUNIT_ASSERT_EQUAL(u"12.00"_ustr, xRow->getString(2)); // numeric + CPPUNIT_ASSERT_EQUAL(u"mind-reading"_ustr, xRow->getString(3)); // varchar + CPPUNIT_ASSERT(xRow->getBoolean(4)); // boolean + + date = xRow->getDate(5); + CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 20 }, date.Day); + CPPUNIT_ASSERT_EQUAL(sal_uInt16{ 5 }, date.Month); + CPPUNIT_ASSERT_EQUAL(sal_Int16{ 1967 }, date.Year); +} + +void MigrationTest::testNumbers() +{ + struct expect_t + { + sal_Int16 id; + OUString number; + }; + + const expect_t expect[] = { + { 1, u"0.0"_ustr }, { 2, u"25.0"_ustr }, { 3, u"26.0"_ustr }, + { 4, u"30.4"_ustr }, { 5, u"45.8"_ustr }, { 6, u"-25.0"_ustr }, + { 7, u"-26.0"_ustr }, { 8, u"-30.4"_ustr }, { 9, u"-45.8"_ustr }, + }; + + // the migration requires the file to be writable + createTempCopy(u"tdf126268.odb"); + uno::Reference<XOfficeDatabaseDocument> const xDocument + = getDocumentForUrl(maTempFile.GetURL()); + + uno::Reference<XConnection> xConnection = getConnectionForDocument(xDocument); + + // select basically everything from the .odb + uno::Reference<XStatement> statement = xConnection->createStatement(); + + uno::Reference<XResultSet> xRes + = statement->executeQuery(u"SELECT ID, Column1, Column2 FROM tableTest ORDER BY ID"_ustr); + uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW); + + // check result + for (auto& e : expect) + { + CPPUNIT_ASSERT(xRes->next()); + CPPUNIT_ASSERT_EQUAL(e.id, xRow->getShort(1)); + CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(2)); //decimal + CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(3)); //numeric + } + CPPUNIT_ASSERT(!xRes->next()); +} + +void MigrationTest::testTime() +{ + struct expect_t + { + sal_Int16 id; + sal_Int16 h, m, s; + }; + + /* The values here assume that our results are in UTC. However, + tdf#119675 "Firebird: Migration: User dialog to set treatment of + datetime and time values during migration" is going to change the + final result of migration. If that change is implemented below + the level we are testing, this test will have to allow for or set + the destination timezone. + */ + const expect_t expect[] + = { { 0, 15, 10, 10 }, { 1, 23, 30, 30 }, { 2, 5, 0, 0 }, { 3, 4, 30, 0 }, + { 4, 3, 15, 10 }, { 5, 5, 0, 0 }, { 6, 3, 22, 22 } }; + + // the migration requires the file to be writable + createTempCopy(u"tdf119625.odb"); + uno::Reference<XOfficeDatabaseDocument> const xDocument + = getDocumentForUrl(maTempFile.GetURL()); + + uno::Reference<XConnection> xConnection = getConnectionForDocument(xDocument); + // at this point migration is already done + /* In the presence of tdf#119625, terminal already has messages + + *value exceeds the range for a valid time + caused by + 'isc_dsql_execute' + + warn:dbaccess:22435:22435:dbaccess/source/filter/hsqldb/hsqlimport.cxx:373: Error during migration + + In this case, we do not expect anything good from the following + code, but I (tje, 2018-09-04) do not know how to detect this + situation. In particular, the migration has been observed to + create the destination table (but truncated after the first + row), and xConnection.is() returns true. + */ + + // select basically everything from the .odb + uno::Reference<XStatement> statement = xConnection->createStatement(); + + uno::Reference<XResultSet> xRes = statement->executeQuery(u" SELECT id, tst_dt, tst_d, tst_t " + " FROM tst_data " + "ORDER BY id"_ustr); + uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW); + + // check result + for (auto& e : expect) + { + CPPUNIT_ASSERT(xRes->next()); + CPPUNIT_ASSERT_EQUAL(xRow->getShort(1), e.id); + auto time_got = xRow->getTime(4); + auto time_expected = css::util::Time(0, e.s, e.m, e.h, false); + auto equal_times = time_got == time_expected; + CPPUNIT_ASSERT(equal_times); + } + CPPUNIT_ASSERT(!xRes->next()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(MigrationTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/dbaccess/qa/unit/tdf119625.cxx b/dbaccess/qa/unit/tdf119625.cxx deleted file mode 100644 index 24189e9a494d..000000000000 --- a/dbaccess/qa/unit/tdf119625.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- 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 "dbtest_base.cxx" - -#include <osl/process.h> -#include <cppunit/plugin/TestPlugIn.h> -#include <com/sun/star/sdbc/XRow.hpp> -#include <cppunit/extensions/HelperMacros.h> -#include <com/sun/star/util/Time.hpp> -#include <officecfg/Office/Common.hxx> - -class Tdf119625Test : public DBTestBase -{ -public: - void testTime(); - - virtual void setUp() override; - - CPPUNIT_TEST_SUITE(Tdf119625Test); - - CPPUNIT_TEST(testTime); - - CPPUNIT_TEST_SUITE_END(); -}; - -void Tdf119625Test::setUp() -{ - DBTestBase::setUp(); - osl_setEnvironment(u"DBACCESS_HSQL_MIGRATION"_ustr.pData, u"1"_ustr.pData); -} - -namespace -{ -struct expect_t -{ - sal_Int16 id; - sal_Int16 h, m, s; -}; -} - -/* The values here assume that our results are in UTC. However, - tdf#119675 "Firebird: Migration: User dialog to set treatment of - datetime and time values during migration" is going to change the - final result of migration. If that change is implemented below - the level we are testing, this test will have to allow for or set - the destination timezone. - */ -const expect_t expect[] = { { 0, 15, 10, 10 }, { 1, 23, 30, 30 }, { 2, 5, 0, 0 }, { 3, 4, 30, 0 }, - { 4, 3, 15, 10 }, { 5, 5, 0, 0 }, { 6, 3, 22, 22 } }; - -void Tdf119625Test::testTime() -{ - bool oldValue = officecfg::Office::Common::Misc::ExperimentalMode::get(); - { - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::ExperimentalMode::set(true, xChanges); - xChanges->commit(); - } - - // the migration requires the file to be writable - createTempCopy(u"tdf119625.odb"); - uno::Reference<XOfficeDatabaseDocument> const xDocument - = getDocumentForUrl(maTempFile.GetURL()); - - uno::Reference<XConnection> xConnection = getConnectionForDocument(xDocument); - // at this point migration is already done - /* In the presence of tdf#119625, terminal already has messages - - *value exceeds the range for a valid time - caused by - 'isc_dsql_execute' - - warn:dbaccess:22435:22435:dbaccess/source/filter/hsqldb/hsqlimport.cxx:373: Error during migration - - In this case, we do not expect anything good from the following - code, but I (tje, 2018-09-04) do not know how to detect this - situation. In particular, the migration has been observed to - create the destination table (but truncated after the first - row), and xConnection.is() returns true. - */ - - // select basically everything from the .odb - uno::Reference<XStatement> statement = xConnection->createStatement(); - - uno::Reference<XResultSet> xRes = statement->executeQuery(u" SELECT id, tst_dt, tst_d, tst_t " - " FROM tst_data " - "ORDER BY id"_ustr); - uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW); - - // check result - for (auto& e : expect) - { - CPPUNIT_ASSERT(xRes->next()); - CPPUNIT_ASSERT_EQUAL(xRow->getShort(1), e.id); - auto time_got = xRow->getTime(4); - auto time_expected = css::util::Time(0, e.s, e.m, e.h, false); - auto equal_times = time_got == time_expected; - CPPUNIT_ASSERT(equal_times); - } - CPPUNIT_ASSERT(!xRes->next()); - - if (!oldValue) - { - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::ExperimentalMode::set(false, xChanges); - xChanges->commit(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(Tdf119625Test); - -CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/dbaccess/qa/unit/tdf126268.cxx b/dbaccess/qa/unit/tdf126268.cxx deleted file mode 100644 index ab8ff19211b2..000000000000 --- a/dbaccess/qa/unit/tdf126268.cxx +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- 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 "dbtest_base.cxx" - -#include <osl/process.h> -#include <cppunit/plugin/TestPlugIn.h> -#include <com/sun/star/sdbc/XRow.hpp> -#include <cppunit/extensions/HelperMacros.h> -#include <officecfg/Office/Common.hxx> - -class Tdf126268Test : public DBTestBase -{ -public: - void testNumbers(); - - virtual void setUp() override; - - CPPUNIT_TEST_SUITE(Tdf126268Test); - - CPPUNIT_TEST(testNumbers); - - CPPUNIT_TEST_SUITE_END(); -}; - -void Tdf126268Test::setUp() -{ - DBTestBase::setUp(); - osl_setEnvironment(u"DBACCESS_HSQL_MIGRATION"_ustr.pData, u"1"_ustr.pData); -} - -namespace -{ -struct expect_t -{ - sal_Int16 id; - OUString number; -}; -} - -const expect_t expect[] = { - { 1, u"0.0"_ustr }, { 2, u"25.0"_ustr }, { 3, u"26.0"_ustr }, - { 4, u"30.4"_ustr }, { 5, u"45.8"_ustr }, { 6, u"-25.0"_ustr }, - { 7, u"-26.0"_ustr }, { 8, u"-30.4"_ustr }, { 9, u"-45.8"_ustr }, -}; - -void Tdf126268Test::testNumbers() -{ - bool oldValue = officecfg::Office::Common::Misc::ExperimentalMode::get(); - { - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::ExperimentalMode::set(true, xChanges); - xChanges->commit(); - } - - // the migration requires the file to be writable - createTempCopy(u"tdf126268.odb"); - uno::Reference<XOfficeDatabaseDocument> const xDocument - = getDocumentForUrl(maTempFile.GetURL()); - - uno::Reference<XConnection> xConnection = getConnectionForDocument(xDocument); - - // select basically everything from the .odb - uno::Reference<XStatement> statement = xConnection->createStatement(); - - uno::Reference<XResultSet> xRes - = statement->executeQuery(u"SELECT ID, Column1, Column2 FROM tableTest ORDER BY ID"_ustr); - uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW); - - // check result - for (auto& e : expect) - { - CPPUNIT_ASSERT(xRes->next()); - CPPUNIT_ASSERT_EQUAL(e.id, xRow->getShort(1)); - CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(2)); //decimal - CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(3)); //numeric - } - CPPUNIT_ASSERT(!xRes->next()); - - if (!oldValue) - { - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::ExperimentalMode::set(false, xChanges); - xChanges->commit(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(Tdf126268Test); - -CPPUNIT_PLUGIN_IMPLEMENT(); commit c406e0005f952420667ad0394bc7f4c34d50abd3 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Feb 28 09:39:31 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Feb 28 13:49:42 2025 +0100 thumbnailview a11y: Drop ThumbnailViewItemAcc::m_aMutex Use SolarMutexGuard in ThumbnailViewItemAcc::ThumbnailViewItemDestroyed instead, like in other methods. This also fixes this build failure I see on Win 11 (due to missing `#include <mutex>`): C:\Users\mwegh\development\git\libreoffice\sfx2\source C:\PROGRA~1\MICROS~1�2\COMMUN~1\VC\Tools\MSVC.42.34433\Include\sstream(19): note: see declaration of 'std' C:\Users\mwegh\development\git\libreoffice\sfx2\source C:\Users\mwegh\development\git\libreoffice\sfx2\source Change-Id: I783c42759df6305038d0901d35d81146084bb3ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182346 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sfx2/source/control/thumbnailviewitemacc.cxx b/sfx2/source/control/thumbnailviewitemacc.cxx index 3e6f3406b2dd..4e8baf3bc89d 100644 --- a/sfx2/source/control/thumbnailviewitemacc.cxx +++ b/sfx2/source/control/thumbnailviewitemacc.cxx @@ -34,8 +34,6 @@ #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <mutex> - using namespace ::com::sun::star; ThumbnailViewItemAcc::ThumbnailViewItemAcc(ThumbnailViewItem* pThumbnailViewItem) @@ -49,7 +47,7 @@ ThumbnailViewItemAcc::~ThumbnailViewItemAcc() void ThumbnailViewItemAcc::ThumbnailViewItemDestroyed() { - std::scoped_lock aGuard( maMutex ); + SolarMutexGuard aSolarGuard; mpThumbnailViewItem = nullptr; } diff --git a/sfx2/source/control/thumbnailviewitemacc.hxx b/sfx2/source/control/thumbnailviewitemacc.hxx index bd5aac054404..98f1e303eac4 100644 --- a/sfx2/source/control/thumbnailviewitemacc.hxx +++ b/sfx2/source/control/thumbnailviewitemacc.hxx @@ -30,7 +30,6 @@ class ThumbnailViewItemAcc css::accessibility::XAccessible> { private: - std::mutex maMutex; ThumbnailViewItem* mpThumbnailViewItem; public: