summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-10-02 18:29:34 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-10-03 10:54:56 +0000
commitdc306db9b51e6f009803f7ba633674dc2840ac08 (patch)
treee542b86da65854722ddda17d629f70e7ffadb0d1
parent52c252882bd293eb7eaf8e5b98fd9c0e21cd827d (diff)
remove anchor test from the conditional format API test
Change-Id: Ifcbcdf03d0d178f865c156fc8a6299741f814bc2 Reviewed-on: https://gerrit.libreoffice.org/29460 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/CppunitTest_sc_anchor_test.mk107
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/extras/anchor.cxx167
-rw-r--r--sc/qa/extras/sccondformats.cxx103
4 files changed, 275 insertions, 103 deletions
diff --git a/sc/CppunitTest_sc_anchor_test.mk b/sc/CppunitTest_sc_anchor_test.mk
new file mode 100644
index 000000000000..8af40604ed84
--- /dev/null
+++ b/sc/CppunitTest_sc_anchor_test.mk
@@ -0,0 +1,107 @@
+# -*- 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_anchor_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_anchor_test, \
+ sc/qa/extras/anchor \
+))
+
+$(eval $(call gb_CppunitTest_use_external,sc_anchor_test,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_anchor_test, \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ drawinglayer \
+ editeng \
+ for \
+ forui \
+ i18nlangtag \
+ msfilter \
+ oox \
+ sal \
+ salhelper \
+ sax \
+ sb \
+ sc \
+ scqahelper \
+ sfx \
+ sot \
+ subsequenttest \
+ svl \
+ svt \
+ svx \
+ svxcore \
+ test \
+ tk \
+ tl \
+ ucbhelper \
+ unotest \
+ utl \
+ vbahelper \
+ vcl \
+ xo \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_anchor_test,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_anchor_test))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_anchor_test))
+$(eval $(call gb_CppunitTest_use_vcl,sc_anchor_test))
+
+$(eval $(call gb_CppunitTest_use_components,sc_anchor_test,\
+ basic/util/sb \
+ comphelper/util/comphelp \
+ configmgr/source/configmgr \
+ dbaccess/util/dba \
+ filter/source/config/cache/filterconfig1 \
+ filter/source/storagefilterdetect/storagefd \
+ 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 \
+ sc/util/sc \
+ sc/util/scd \
+ sc/util/scfilt \
+ $(call gb_Helper_optional,SCRIPTING, \
+ sc/util/vbaobj) \
+ sfx2/util/sfx \
+ sot/util/sot \
+ svl/source/fsstor/fsstorage \
+ 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 \
+ svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_anchor_test))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index cdba1feb1540..5493c09eb648 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -89,6 +89,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
JunitTest_sc_unoapi_5 \
JunitTest_sc_unoapi_6 \
JunitTest_sc_unoapi_7 \
+ CppunitTest_sc_anchor_test \
CppunitTest_sc_annotationshapeobj \
CppunitTest_sc_outlineobj \
CppunitTest_sc_styleloaderobj \
diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx
new file mode 100644
index 000000000000..823370529e0c
--- /dev/null
+++ b/sc/qa/extras/anchor.cxx
@@ -0,0 +1,167 @@
+/* -*- 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/calc_unoapi_test.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdpage.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <unonames.hxx>
+
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+
+#include "sc.hrc"
+
+using namespace css;
+
+namespace sc_apitest {
+
+class ScAnchorTest : public CalcUnoApiTest
+{
+public:
+ ScAnchorTest();
+
+ virtual void tearDown() override;
+
+ void testUndoAnchor();
+
+ CPPUNIT_TEST_SUITE(ScAnchorTest);
+ CPPUNIT_TEST(testUndoAnchor);
+ CPPUNIT_TEST_SUITE_END();
+private:
+
+ uno::Reference< lang::XComponent > mxComponent;
+};
+
+ScAnchorTest::ScAnchorTest()
+ : CalcUnoApiTest("sc/qa/unit/data/ods")
+{
+}
+
+
+void ScAnchorTest::testUndoAnchor()
+{
+ OUString aFileURL;
+ createFileURL("document_with_linked_graphic.ods", aFileURL);
+ // open the document with graphic included
+ uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(xComponent.is());
+
+ // Get the document model
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+ CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+
+ ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
+ CPPUNIT_ASSERT(pDocSh);
+
+ // Check whether graphic imported well
+ ScDocument& rDoc = pDocSh->GetDocument();
+ ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+ CPPUNIT_ASSERT(pDrawLayer);
+
+ const SdrPage *pPage = pDrawLayer->GetPage(0);
+ CPPUNIT_ASSERT(pPage);
+
+ SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(0));
+ CPPUNIT_ASSERT(pObject);
+ CPPUNIT_ASSERT(pObject->IsLinkedGraphic());
+
+ const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
+ CPPUNIT_ASSERT(!rGraphicObj.IsSwappedOut());
+ CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
+
+ // Get the document controller
+ ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
+ CPPUNIT_ASSERT(pViewShell);
+
+ // Get the draw view of the document
+ ScDrawView* pDrawView = pViewShell->GetViewData().GetScDrawView();
+ CPPUNIT_ASSERT(pDrawView);
+
+ // Select graphic object
+ pDrawView->MarkNextObj();
+ CPPUNIT_ASSERT(pDrawView->AreObjectsMarked() );
+
+ // Set Cell Anchor
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObject, rDoc, 0);
+ // Check state
+ ScAnchorType oldType = ScDrawLayer::GetAnchorType(*pObject);
+ CPPUNIT_ASSERT(oldType == SCA_CELL );
+
+ // Change all selected objects to page anchor
+ pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_PAGE);
+ // Check state
+ ScAnchorType newType = ScDrawLayer::GetAnchorType(*pObject);
+ CPPUNIT_ASSERT(newType == SCA_PAGE );
+
+ // Undo and check its result.
+ SfxUndoManager* pUndoMgr = rDoc.GetUndoManager();
+ CPPUNIT_ASSERT(pUndoMgr);
+ pUndoMgr->Undo();
+
+ // Check anchor type
+ CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) );
+ CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
+
+ pUndoMgr->Redo();
+
+ // Check anchor type
+ CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) );
+ CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
+
+ ScDrawLayer::SetPageAnchored(*pObject);
+ // Check state
+ oldType = ScDrawLayer::GetAnchorType(*pObject);
+ CPPUNIT_ASSERT(oldType == SCA_PAGE );
+
+ // Change all selected objects to cell anchor
+ pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_CELL);
+ // Check state
+ newType = ScDrawLayer::GetAnchorType(*pObject);
+ CPPUNIT_ASSERT(newType == SCA_CELL );
+
+ pUndoMgr->Undo();
+
+ // Check anchor type
+ CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) );
+ CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
+
+ pUndoMgr->Redo();
+
+ // Check anchor type
+ CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) );
+ CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
+
+ xComponent->dispose();
+}
+
+void ScAnchorTest::tearDown()
+{
+ if (mxComponent.is())
+ {
+ closeDocument(mxComponent);
+ }
+
+ CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScAnchorTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/sccondformats.cxx b/sc/qa/extras/sccondformats.cxx
index f8f5871f99d4..5861824d4970 100644
--- a/sc/qa/extras/sccondformats.cxx
+++ b/sc/qa/extras/sccondformats.cxx
@@ -38,11 +38,9 @@ public:
uno::Reference< uno::XInterface > init();
void testCondFormat();
- void testUndoAnchor();
CPPUNIT_TEST_SUITE(ScConditionalFormatTest);
CPPUNIT_TEST(testCondFormat);
- CPPUNIT_TEST(testUndoAnchor);
CPPUNIT_TEST_SUITE_END();
private:
@@ -113,107 +111,6 @@ void ScConditionalFormatTest::testCondFormat()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSheetConditionalEntries->getCount());
}
-void ScConditionalFormatTest::testUndoAnchor()
-{
- OUString aFileURL;
- createFileURL("document_with_linked_graphic.ods", aFileURL);
- // open the document with graphic included
- uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileURL);
- CPPUNIT_ASSERT(xComponent.is());
-
- // Get the document model
- SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
- CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
-
- ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
- CPPUNIT_ASSERT(pDocSh);
-
- // Check whether graphic imported well
- ScDocument& rDoc = pDocSh->GetDocument();
- ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
- CPPUNIT_ASSERT(pDrawLayer);
-
- const SdrPage *pPage = pDrawLayer->GetPage(0);
- CPPUNIT_ASSERT(pPage);
-
- SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(0));
- CPPUNIT_ASSERT(pObject);
- CPPUNIT_ASSERT(pObject->IsLinkedGraphic());
-
- const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
- CPPUNIT_ASSERT(!rGraphicObj.IsSwappedOut());
- CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
- CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
-
- // Get the document controller
- ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
- CPPUNIT_ASSERT(pViewShell);
-
- // Get the draw view of the document
- ScDrawView* pDrawView = pViewShell->GetViewData().GetScDrawView();
- CPPUNIT_ASSERT(pDrawView);
-
- // Select graphic object
- pDrawView->MarkNextObj();
- CPPUNIT_ASSERT(pDrawView->AreObjectsMarked() );
-
- // Set Cell Anchor
- ScDrawLayer::SetCellAnchoredFromPosition(*pObject, rDoc, 0);
- // Check state
- ScAnchorType oldType = ScDrawLayer::GetAnchorType(*pObject);
- CPPUNIT_ASSERT(oldType == SCA_CELL );
-
- // Change all selected objects to page anchor
- pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_PAGE);
- // Check state
- ScAnchorType newType = ScDrawLayer::GetAnchorType(*pObject);
- CPPUNIT_ASSERT(newType == SCA_PAGE );
-
- // Undo and check its result.
- SfxUndoManager* pUndoMgr = rDoc.GetUndoManager();
- CPPUNIT_ASSERT(pUndoMgr);
- pUndoMgr->Undo();
-
- // Check anchor type
- CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) );
- CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
- CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
-
- pUndoMgr->Redo();
-
- // Check anchor type
- CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) );
- CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
- CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
-
- ScDrawLayer::SetPageAnchored(*pObject);
- // Check state
- oldType = ScDrawLayer::GetAnchorType(*pObject);
- CPPUNIT_ASSERT(oldType == SCA_PAGE );
-
- // Change all selected objects to cell anchor
- pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_CELL);
- // Check state
- newType = ScDrawLayer::GetAnchorType(*pObject);
- CPPUNIT_ASSERT(newType == SCA_CELL );
-
- pUndoMgr->Undo();
-
- // Check anchor type
- CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) );
- CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
- CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
-
- pUndoMgr->Redo();
-
- // Check anchor type
- CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) );
- CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
- CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
-
- xComponent->dispose();
-}
-
void ScConditionalFormatTest::tearDown()
{
if (mxComponent.is())