diff options
author | Caolán McNamara <caolanm@redhat.com> | 2010-12-07 11:12:13 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2010-12-07 11:12:13 +0000 |
commit | d77dcdc56bad0fd7f4145fb141d0fe0de0cff996 (patch) | |
tree | aa97803157974f84b5dbbc0bd9e68b97481f7a0f /starmath/qa | |
parent | 914691ae9acbeb3208ea9dae46e43c3d3fb9fab3 (diff) |
cppunit: add some more zoom tests
Diffstat (limited to 'starmath/qa')
-rw-r--r-- | starmath/qa/cppunit/test_starmath.cxx | 67 |
1 files changed, 64 insertions, 3 deletions
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx index aab6942bda3c..1b08ae019bc4 100644 --- a/starmath/qa/cppunit/test_starmath.cxx +++ b/starmath/qa/cppunit/test_starmath.cxx @@ -15,6 +15,7 @@ #include <document.hxx> #include <view.hxx> +#include <sfx2/sfxmodelfactory.hxx> #include <sfx2/bindings.hxx> #include <sfx2/request.hxx> #include <sfx2/dispatch.hxx> @@ -24,6 +25,8 @@ #include <editeng/editeng.hxx> #include <editeng/editview.hxx> +#include <svx/zoomitem.hxx> + #include "preextstl.h" #include <cppunit/TestSuite.h> #include <cppunit/TestFixture.h> @@ -86,7 +89,10 @@ void Test::setUp() SmDLL::Init(); - m_xDocShRef = new SmDocShell(SFXOBJECTSHELL_STD_NORMAL); + m_xDocShRef = new SmDocShell( + SFXMODEL_EMBEDDED_OBJECT | + SFXMODEL_DISABLE_EMBEDDED_SCRIPTS | + SFXMODEL_DISABLE_DOCUMENT_RECOVERY); m_xDocShRef->DoInitNew(0); SfxViewFrame *pViewFrame = SfxViewFrame::LoadHiddenDocument(*m_xDocShRef, 0); @@ -308,13 +314,68 @@ void Test::tViewZoom() CPPUNIT_ASSERT_MESSAGE("Should be equal", nFinalZoom == nOrigZoom); } + sal_uInt16 nOptimalZoom=0; + + { + SfxRequest aZoom(SID_FITINWINDOW, SFX_CALLMODE_SYNCHRON, m_pViewShell->GetPool()); + m_pViewShell->Execute(aZoom); + nOptimalZoom = rGraphicWindow.GetZoom(); + CPPUNIT_ASSERT_MESSAGE("Should be about 800%", nOptimalZoom > nOrigZoom); + } + + { + SfxItemSet aSet(m_xDocShRef->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM); + aSet.Put(SvxZoomItem(SVX_ZOOM_OPTIMAL, 0)); + SfxRequest aZoom(SID_ATTR_ZOOM, SFX_CALLMODE_SYNCHRON, aSet); + m_pViewShell->Execute(aZoom); + nFinalZoom = rGraphicWindow.GetZoom(); + CPPUNIT_ASSERT_MESSAGE("Should be optimal zoom", nFinalZoom == nOptimalZoom); + } + +#if 0 + //TO-DO: switch from embedded to normal to get these meaningfull { - SfxRequest aZoomOut(SID_FITINWINDOW, SFX_CALLMODE_SYNCHRON, m_pViewShell->GetPool()); + SfxRequest aZoomOut(SID_ZOOMOUT, SFX_CALLMODE_SYNCHRON, m_pViewShell->GetPool()); m_pViewShell->Execute(aZoomOut); nFinalZoom = rGraphicWindow.GetZoom(); - CPPUNIT_ASSERT_MESSAGE("Should be about 800%", nFinalZoom > nOrigZoom); + CPPUNIT_ASSERT_MESSAGE("Should not be optimal zoom", nFinalZoom != nOptimalZoom); + + SfxItemSet aSet(m_xDocShRef->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM); + aSet.Put(SvxZoomItem(SVX_ZOOM_PAGEWIDTH, 0)); + SfxRequest aZoom(SID_ATTR_ZOOM, SFX_CALLMODE_SYNCHRON, aSet); + m_pViewShell->Execute(aZoom); + nFinalZoom = rGraphicWindow.GetZoom(); + CPPUNIT_ASSERT_MESSAGE("Should be same as optimal zoom", nFinalZoom == nOptimalZoom); } + { + SfxRequest aZoomOut(SID_ZOOMOUT, SFX_CALLMODE_SYNCHRON, m_pViewShell->GetPool()); + m_pViewShell->Execute(aZoomOut); + nFinalZoom = rGraphicWindow.GetZoom(); + CPPUNIT_ASSERT_MESSAGE("Should not be optimal zoom", nFinalZoom != nOptimalZoom); + + SfxItemSet aSet(m_xDocShRef->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM); + aSet.Put(SvxZoomItem(SVX_ZOOM_WHOLEPAGE, 0)); + SfxRequest aZoom(SID_ATTR_ZOOM, SFX_CALLMODE_SYNCHRON, aSet); + m_pViewShell->Execute(aZoom); + nFinalZoom = rGraphicWindow.GetZoom(); + CPPUNIT_ASSERT_MESSAGE("Should be same as optimal zoom", nFinalZoom == nOptimalZoom); + } +#endif + + { + SfxRequest aZoomOut(SID_ZOOMOUT, SFX_CALLMODE_SYNCHRON, m_pViewShell->GetPool()); + m_pViewShell->Execute(aZoomOut); + nFinalZoom = rGraphicWindow.GetZoom(); + CPPUNIT_ASSERT_MESSAGE("Should not be optimal zoom", nFinalZoom != nOptimalZoom); + + SfxItemSet aSet(m_xDocShRef->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM); + aSet.Put(SvxZoomItem(SVX_ZOOM_PERCENT, 50)); + SfxRequest aZoom(SID_ATTR_ZOOM, SFX_CALLMODE_SYNCHRON, aSet); + m_pViewShell->Execute(aZoom); + nFinalZoom = rGraphicWindow.GetZoom(); + CPPUNIT_ASSERT_MESSAGE("Should be 50%", nFinalZoom == 50); + } } void Test::testDocument() |