diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-06-21 11:21:18 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2016-08-18 02:39:08 +0200 |
commit | a7c3ced4afaa3ca0c0cfc6a951b5f0d404836376 (patch) | |
tree | c3a5081f79b41495e66b591a01dc93db1f7b6b1a /sc | |
parent | 181932b31ea9c07a9bec3677e73b67a9a6d4e3f2 (diff) |
screenshots: opening some sc dialogs from cppunit
Change-Id: I4e56f0264ada77e24f5d71fa9eaf48e5eedaaae8
Diffstat (limited to 'sc')
-rw-r--r-- | sc/CppunitTest_sc_screenshots.mk | 63 | ||||
-rw-r--r-- | sc/qa/unit/screenshots/data/empty.ods | bin | 0 -> 6873 bytes | |||
-rw-r--r-- | sc/qa/unit/screenshots/screenshots.cxx | 173 |
3 files changed, 236 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_screenshots.mk b/sc/CppunitTest_sc_screenshots.mk new file mode 100644 index 000000000000..ac1aa41d3709 --- /dev/null +++ b/sc/CppunitTest_sc_screenshots.mk @@ -0,0 +1,63 @@ +# -*- 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,sc_screenshots)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_screenshots, \ + sc/qa/unit/screenshots/screenshots \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_screenshots, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + sal \ + sfx \ + svl \ + svt \ + svxcore \ + sc \ + scui \ + test \ + unotest \ + vcl \ + tl \ + utl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sc_screenshots,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_screenshots,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sc_screenshots,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sc_screenshots)) +$(eval $(call gb_CppunitTest_use_vcl_non_headless_with_windows,sc_screenshots)) + +$(eval $(call gb_CppunitTest_use_rdb,sc_screenshots,services)) + +$(eval $(call gb_CppunitTest_use_instdir_configuration,sc_screenshots)) + +$(call gb_CppunitTest_get_target,sc_screenshots) : $(call gb_AllLangResTarget_get_target,sc) + +# vim: set noet sw=4 ts=4: diff --git a/sc/qa/unit/screenshots/data/empty.ods b/sc/qa/unit/screenshots/data/empty.ods Binary files differnew file mode 100644 index 000000000000..14b4232189f5 --- /dev/null +++ b/sc/qa/unit/screenshots/data/empty.ods diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx new file mode 100644 index 000000000000..fb27cab755db --- /dev/null +++ b/sc/qa/unit/screenshots/screenshots.cxx @@ -0,0 +1,173 @@ +/* -*- 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/bootstrapfixture.hxx> +#include <unotest/macros_test.hxx> +#include <test/xmltesttools.hxx> + +#include <com/sun/star/frame/Desktop.hpp> +#include <comphelper/dispatchcommand.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/propertysequence.hxx> +#include <comphelper/string.hxx> +#include <editeng/editids.hrc> +#include <editeng/editview.hxx> +#include <editeng/outliner.hxx> +#include <osl/conditn.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <svl/srchitem.hxx> + +#include <tabvwsh.hxx> +#include <docsh.hxx> +#include <document.hxx> +#include <docuno.hxx> +#include <scabstdlg.hxx> +#include <reffact.hxx> + +#include <sc.hrc> + +using namespace css; + +#if !defined(WNT) && !defined(MACOSX) +static const char* DATA_DIRECTORY = "/sc/qa/unit/screenshots/data/"; +#endif + +class ScScreenshotTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +{ +public: + ScScreenshotTest(); + virtual void setUp() SAL_OVERRIDE; + virtual void tearDown() SAL_OVERRIDE; + +#if !defined(WNT) && !defined(MACOSX) + void testOpeningSomeDialog(); + //void testOpeningModelessDialogs(); +#endif + + CPPUNIT_TEST_SUITE(ScScreenshotTest); +#if !defined(WNT) && !defined(MACOSX) + CPPUNIT_TEST(testOpeningSomeDialog); + //CPPUNIT_TEST(testOpeningModelessDialogs); +#endif + CPPUNIT_TEST_SUITE_END(); + +private: +#if !defined(WNT) && !defined(MACOSX) + ScModelObj* createDoc(const char* pName); + +#endif + + uno::Reference<lang::XComponent> mxComponent; +}; + +ScScreenshotTest::ScScreenshotTest() +{ +} + +void ScScreenshotTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); +} + +void ScScreenshotTest::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +#if !defined(WNT) && !defined(MACOSX) +ScModelObj* ScScreenshotTest::createDoc(const char* pName) +{ + if (mxComponent.is()) + mxComponent->dispose(); + mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + return pModelObj; +} + +void ScScreenshotTest::testOpeningSomeDialog() +{ + ScModelObj* pModelObj = createDoc("empty.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + + // display insert sheet dialog + //uno::Sequence<beans::PropertyValue> aArgs; + //comphelper::dispatchCommand(".uno:Insert", aArgs); + + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + + ScDocShellRef xDocSh = dynamic_cast<ScDocShell*>(pFoundShell); + CPPUNIT_ASSERT(xDocSh != nullptr); + + ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false); + CPPUNIT_ASSERT(pViewShell != nullptr); + + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + CPPUNIT_ASSERT( pFact != nullptr ); + + ScViewData& rViewData = pViewShell->GetViewData(); + SCTAB nTabSelCount = rViewData.GetMarkData().GetSelectCount(); + std::unique_ptr<AbstractScInsertTableDlg> pDlg( pFact->CreateScInsertTableDlg( + pViewShell->GetDialogParent(), rViewData, nTabSelCount, false)); + CPPUNIT_ASSERT( pDlg != nullptr ); + + pDlg->Execute(); + + std::unique_ptr<AbstractScDeleteCellDlg> pDlg2( pFact->CreateScDeleteCellDlg( + pViewShell->GetDialogParent(), false)); + CPPUNIT_ASSERT( pDlg2 != nullptr ); + + pDlg2->Execute(); + + std::unique_ptr<AbstractScInsertContentsDlg> pDlg3( pFact->CreateScInsertContentsDlg( + pViewShell->GetDialogParent())); + CPPUNIT_ASSERT( pDlg3 != nullptr ); + + pDlg3->Execute(); + + std::unique_ptr<AbstractScColRowLabelDlg> pDlg4( pFact->CreateScColRowLabelDlg( + pViewShell->GetDialogParent(), true, false)); + CPPUNIT_ASSERT( pDlg4 != nullptr ); + + pDlg4->Execute(); + + std::unique_ptr<AbstractScDataPilotDatabaseDlg> pDlg5( pFact->CreateScDataPilotDatabaseDlg( + pViewShell->GetDialogParent())); + CPPUNIT_ASSERT( pDlg5 != nullptr ); + + pDlg5->Execute(); + + std::unique_ptr<AbstractScDataPilotSourceTypeDlg> pDlg6( pFact->CreateScDataPilotSourceTypeDlg( + pViewShell->GetDialogParent(), true)); + CPPUNIT_ASSERT( pDlg6 != nullptr ); + + pDlg6->Execute(); + + std::unique_ptr<AbstractScDeleteContentsDlg> pDlg7( pFact->CreateScDeleteContentsDlg( + pViewShell->GetDialogParent())); + CPPUNIT_ASSERT( pDlg7 != nullptr ); + + pDlg7->Execute(); + +} + +#endif + +CPPUNIT_TEST_SUITE_REGISTRATION(ScScreenshotTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |