diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-09-08 20:55:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-09 10:36:12 +0200 |
commit | 0be6168c5a7b1493a22222dc0967b5e8a0153386 (patch) | |
tree | eec28f9fd273edea33b01edd7a5c408734f7f85f /sw/qa/uibase/uiview/uiview.cxx | |
parent | 63d4d3421fec5a4e9e88dcee2992cda38cc7452a (diff) |
sw: rename CppunitTest_sw_updateall_object_replacements to sw_uibase_uiview
All these new test suites are named in a way, so that in case the fix is
in sw/source/foo/bar/, then the matching test suite is sw_foo_bar.
Rename to this schema, so next time a bug is fixed in that directory, we
don't need to add a new suite.
Change-Id: I968711754cb587cc2f97fff6431be416b477728f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102274
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/uibase/uiview/uiview.cxx')
-rw-r--r-- | sw/qa/uibase/uiview/uiview.cxx | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx new file mode 100644 index 000000000000..8827cea10752 --- /dev/null +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -0,0 +1,92 @@ +/* -*- 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 <swmodeltestbase.hxx> + +#include <unotools/mediadescriptor.hxx> +#include <comphelper/processfactory.hxx> +#include <osl/file.hxx> + +#include <com/sun/star/frame/DispatchHelper.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> + +#include <unotxdoc.hxx> +#include <docsh.hxx> +#include <wrtsh.hxx> +#include <swdtflvr.hxx> + +char const DATA_DIRECTORY[] = "/sw/qa/uibase/uiview/data/"; + +/// Covers sw/source/uibase/uiview/ fixes. +class SwUibaseUiviewTest : public SwModelTestBase +{ +}; + +CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateAllObjectReplacements) +{ + // Make a temporary copy of the test document + utl::TempFile tmp; + tmp.EnableKillingFile(); + OUString sTempCopy = tmp.GetURL(); + CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, + osl::File::copy(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "updateall-objectreplacements.odt", + sTempCopy)); + + /* BASIC code that exhibits the problem: + + desktop = CreateUnoService("com.sun.star.frame.Desktop") + Dim props(0) as new com.sun.star.beans.PropertyValue + props(0).Name = "Hidden" + props(0).Value = true + component = desktop.loadComponentFromURL("file://.../test.odt", "_default", 0, props) + Wait 1000 ' workaround + dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") + frame = component.CurrentController.Frame + dispatcher.executeDispatch(frame, ".uno:UpdateAll", "", 0, Array()) + component.storeSelf(Array()) + component.dispose() + */ + + uno::Reference<lang::XMultiServiceFactory> xFactory(comphelper::getProcessServiceFactory()); + + // Load the copy + uno::Reference<uno::XInterface> xInterface + = xFactory->createInstance("com.sun.star.frame.Desktop"); + uno::Reference<frame::XComponentLoader> xComponentLoader(xInterface, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aLoadArgs(1); + aLoadArgs[0].Name = "Hidden"; + aLoadArgs[0].Value <<= true; + mxComponent = xComponentLoader->loadComponentFromURL(sTempCopy, "_default", 0, aLoadArgs); + + // Perform the .uno:UpdateAll call and save + xInterface = xFactory->createInstance("com.sun.star.frame.DispatchHelper"); + uno::Reference<frame::XDispatchHelper> xDispatchHelper(xInterface, uno::UNO_QUERY); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<frame::XDispatchProvider> xDispatchProvider( + xModel->getCurrentController()->getFrame(), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aNoArgs; + xDispatchHelper->executeDispatch(xDispatchProvider, ".uno:UpdateAll", OUString(), 0, aNoArgs); + uno::Reference<frame::XStorable2> xStorable(mxComponent, uno::UNO_QUERY); + xStorable->storeSelf(aNoArgs); + + // Check the contents of the updated copy and verify that ObjectReplacements are there + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess + = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(xFactory), + sTempCopy); + + CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Components")); + CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Components_1")); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |