diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sfx2/qa/cppunit/view.cxx | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sfx2/qa/cppunit/view.cxx')
-rw-r--r-- | sfx2/qa/cppunit/view.cxx | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/sfx2/qa/cppunit/view.cxx b/sfx2/qa/cppunit/view.cxx new file mode 100644 index 0000000000..725cb5d02c --- /dev/null +++ b/sfx2/qa/cppunit/view.cxx @@ -0,0 +1,64 @@ +/* -*- 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 <test/unoapi_test.hxx> + +#include <com/sun/star/drawing/XDrawView.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <sfx2/app.hxx> +#include <sfx2/sfxsids.hrc> +#include <sfx2/viewfrm.hxx> +#include <svl/itemset.hxx> +#include <svl/intitem.hxx> +#include <sfx2/request.hxx> +#include <sfx2/bindings.hxx> + +using namespace com::sun::star; + +/// Covers sfx2/source/view/ fixes. +class Sfx2ViewTest : public UnoApiTest +{ +public: + Sfx2ViewTest() + : UnoApiTest("/sfx2/qa/cppunit/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Sfx2ViewTest, testReloadPage) +{ + // Load a document, which has 2 pages. + loadFromFile(u"reload-page.odg"); + + // Reload, and request to start on page 2. + SfxViewFrame* pFrame = SfxViewFrame::Current(); + SfxAllItemSet aSet(SfxGetpApp()->GetPool()); + aSet.Put(SfxInt32Item(SID_PAGE_NUMBER, 1)); + SfxRequest aReq(SID_RELOAD, SfxCallMode::SLOT, aSet); + pFrame->ExecReload_Impl(aReq); + uno::Reference<frame::XModel> xModel = SfxObjectShell::Current()->GetBaseModel(); + mxComponent = xModel; + + // Check the current page after reload. + uno::Reference<drawing::XDrawView> xController(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPage(xController->getCurrentPage(), uno::UNO_QUERY); + sal_Int32 nPage{}; + xPage->getPropertyValue("Number") >>= nPage; + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 1 + // i.e. the document was opened on page 1, not page 2, SID_PAGE_NUMBER was ignored. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), nPage); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |