diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-10-02 18:29:34 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-10-03 10:54:56 +0000 |
commit | dc306db9b51e6f009803f7ba633674dc2840ac08 (patch) | |
tree | e542b86da65854722ddda17d629f70e7ffadb0d1 /sc/qa | |
parent | 52c252882bd293eb7eaf8e5b98fd9c0e21cd827d (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>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/extras/anchor.cxx | 167 | ||||
-rw-r--r-- | sc/qa/extras/sccondformats.cxx | 103 |
2 files changed, 167 insertions, 103 deletions
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()) |