1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/config.h>
12 #include <config_fonts.h>
13 #include <vcl/print.hxx>
15 #include <test/bootstrapfixture.hxx>
18 #include <document.hxx>
21 #include <tmpdevice.hxx>
23 #include <sfx2/sfxmodelfactory.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <sfx2/request.hxx>
26 #include <sfx2/dispatch.hxx>
28 #include <editeng/editeng.hxx>
30 #include <sfx2/zoomitem.hxx>
31 #include <starmath.hrc>
34 typedef rtl::Reference
<SmDocShell
> SmDocShellRef
;
36 using namespace ::com::sun::star
;
40 class Test
: public test::BootstrapFixture
46 virtual void setUp() override
;
47 virtual void tearDown() override
;
53 void ParseErrorUnexpectedToken();
54 void ParseErrorPoundExpected();
55 void ParseErrorColorExpected();
56 void ParseErrorLgroupExpected();
57 void ParseErrorRgroupExpected();
58 void ParseErrorLbraceExpected();
59 void ParseErrorRbraceExpected();
60 void ParseErrorParentMismatch();
61 void ParseErrorRightExpected();
62 void ParseErrorFontExpected();
63 void ParseErrorSizeExpected();
64 void ParseErrorDoubleAlign();
65 void ParseErrorDoubleSubsupscript();
67 void replacePlaceholder();
71 void testSmTmpDeviceRestoreFont();
74 CPPUNIT_TEST_SUITE(Test
);
75 CPPUNIT_TEST(editUndoRedo
);
76 CPPUNIT_TEST(editMarker
);
77 CPPUNIT_TEST(editFailure
);
78 CPPUNIT_TEST(ParseErrorUnexpectedToken
);
79 CPPUNIT_TEST(ParseErrorPoundExpected
);
80 CPPUNIT_TEST(ParseErrorColorExpected
);
81 CPPUNIT_TEST(ParseErrorLgroupExpected
);
82 CPPUNIT_TEST(ParseErrorRgroupExpected
);
83 CPPUNIT_TEST(ParseErrorLbraceExpected
);
84 CPPUNIT_TEST(ParseErrorRbraceExpected
);
85 CPPUNIT_TEST(ParseErrorParentMismatch
);
86 CPPUNIT_TEST(ParseErrorRightExpected
);
87 CPPUNIT_TEST(ParseErrorFontExpected
);
88 CPPUNIT_TEST(ParseErrorSizeExpected
);
89 CPPUNIT_TEST(ParseErrorDoubleAlign
);
90 CPPUNIT_TEST(ParseErrorDoubleSubsupscript
);
91 CPPUNIT_TEST(replacePlaceholder
);
92 CPPUNIT_TEST(viewZoom
);
94 CPPUNIT_TEST(testSmTmpDeviceRestoreFont
);
96 CPPUNIT_TEST_SUITE_END();
99 SfxBindings m_aBindings
;
100 std::unique_ptr
<SfxDispatcher
> m_pDispatcher
;
101 VclPtr
<SmCmdBoxWindow
> m_pSmCmdBoxWindow
;
102 SmDocShellRef m_xDocShRef
;
103 SmViewShell
*m_pViewShell
;
107 : m_pViewShell(nullptr)
113 BootstrapFixture::setUp();
117 m_xDocShRef
= new SmDocShell(
118 SfxModelFlags::EMBEDDED_OBJECT
|
119 SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS
|
120 SfxModelFlags::DISABLE_DOCUMENT_RECOVERY
);
121 m_xDocShRef
->DoInitNew();
123 SfxViewFrame
*pViewFrame
= SfxViewFrame::LoadHiddenDocument(*m_xDocShRef
, SFX_INTERFACE_NONE
);
125 CPPUNIT_ASSERT_MESSAGE("Should have a SfxViewFrame", pViewFrame
);
127 m_pDispatcher
.reset(new SfxDispatcher(pViewFrame
));
128 m_aBindings
.SetDispatcher(m_pDispatcher
.get());
129 m_aBindings
.EnterRegistrations();
130 m_pSmCmdBoxWindow
.reset(VclPtr
<SmCmdBoxWindow
>::Create(&m_aBindings
, nullptr, nullptr));
131 m_aBindings
.LeaveRegistrations();
132 m_pViewShell
= m_pSmCmdBoxWindow
->GetView();
133 CPPUNIT_ASSERT_MESSAGE("Should have a SmViewShell", m_pViewShell
);
136 void Test::tearDown()
138 m_pSmCmdBoxWindow
.disposeAndClear();
139 m_pDispatcher
.reset();
140 m_xDocShRef
->DoClose();
143 BootstrapFixture::tearDown();
147 void Test::testSmTmpDeviceRestoreFont()
149 ScopedVclPtrInstance
<Printer
> pPrinter
;
151 OUString
aFontName(u
"Linux Libertine G"_ustr
);
152 CPPUNIT_ASSERT(pPrinter
->IsFontAvailable(aFontName
));
154 vcl::Font aOriginalFont
= pPrinter
->GetFont();
155 aOriginalFont
.SetColor(COL_RED
);
156 pPrinter
->SetTextColor(COL_RED
);
161 bool bUseMap100th_mm
= true;
162 SmTmpDevice
aTmpDev(*pPrinter
, bUseMap100th_mm
);
164 aNewFont
= pPrinter
->GetFont();
165 aNewFont
.SetFamilyName(aFontName
);
166 aTmpDev
.SetFont(aNewFont
);
168 CPPUNIT_ASSERT_EQUAL(aFontName
, pPrinter
->GetFont().GetFamilyName());
169 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pPrinter
->GetTextColor());
172 CPPUNIT_ASSERT(aNewFont
!= pPrinter
->GetFont());
173 CPPUNIT_ASSERT_EQUAL(COL_RED
, pPrinter
->GetTextColor());
177 void Test::editMarker()
179 SmEditWindow
& rEditWindow
= m_pSmCmdBoxWindow
->GetEditWindow();
181 OUString
sMarkedText(u
"<?> under <?> under <?>"_ustr
);
182 rEditWindow
.SetText(sMarkedText
);
184 OUString sFinalText
= rEditWindow
.GetText();
185 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be equal text", sMarkedText
, sFinalText
);
189 ESelection aSelection
;
191 rEditWindow
.SelNextMark();
192 rEditWindow
.Delete();
193 rEditWindow
.InsertText(u
"a"_ustr
);
195 rEditWindow
.SelNextMark();
196 rEditWindow
.SelNextMark();
197 rEditWindow
.Delete();
198 rEditWindow
.InsertText(u
"c"_ustr
);
200 // should be safe i.e. do nothing
201 rEditWindow
.SelNextMark();
202 aSelection
= rEditWindow
.GetSelection();
203 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection
.start
.nPara
);
204 CPPUNIT_ASSERT_EQUAL(sal_Int32(19), aSelection
.start
.nIndex
);
205 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection
.end
.nPara
);
206 CPPUNIT_ASSERT_EQUAL(sal_Int32(19), aSelection
.end
.nIndex
);
208 rEditWindow
.SelPrevMark();
209 rEditWindow
.Delete();
210 rEditWindow
.InsertText(u
"b"_ustr
);
212 // tdf#106116: should be safe i.e. do nothing
213 rEditWindow
.SelPrevMark();
214 aSelection
= rEditWindow
.GetSelection();
215 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection
.start
.nPara
);
216 CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aSelection
.start
.nIndex
);
217 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection
.end
.nPara
);
218 CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aSelection
.end
.nIndex
);
221 OUString sFinalText
= rEditWindow
.GetText();
222 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a under b under c", u
"a under b under c"_ustr
, sFinalText
);
226 rEditWindow
.SetText(OUString());
231 void Test::editFailure()
233 m_xDocShRef
->SetText(u
"color a b over {a/}"_ustr
);
235 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
237 CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::ColorExpected",
239 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a SmParseError::ColorExpected",
240 SmParseError::ColorExpected
, pErrorDesc
->m_eType
);
242 pErrorDesc
= m_xDocShRef
->GetParser()->PrevError();
244 CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::UnexpectedChar",
246 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a SmParseError::UnexpectedChar",
247 SmParseError::UnexpectedChar
, pErrorDesc
->m_eType
);
249 pErrorDesc
= m_xDocShRef
->GetParser()->PrevError();
251 CPPUNIT_ASSERT_MESSAGE("Should be a SmParseError::RgroupExpected",
253 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be a SmParseError::RgroupExpected",
254 SmParseError::RgroupExpected
, pErrorDesc
->m_eType
);
256 const SmErrorDesc
*pLastErrorDesc
= m_xDocShRef
->GetParser()->PrevError();
258 CPPUNIT_ASSERT_MESSAGE("Should be three syntax errors",
260 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be three syntax errors",
261 pErrorDesc
, pLastErrorDesc
);
264 void Test::ParseErrorUnexpectedToken()
266 m_xDocShRef
->SetText(u
"\\foo"_ustr
);
267 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
268 CPPUNIT_ASSERT(pErrorDesc
);
269 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::UnexpectedToken expected",
270 SmParseError::UnexpectedToken
, pErrorDesc
->m_eType
);
273 void Test::ParseErrorPoundExpected()
275 m_xDocShRef
->SetText(u
"matrix {1#2##a##b#c}"_ustr
);
276 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
277 CPPUNIT_ASSERT(pErrorDesc
);
278 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::PoundExpected expected",
279 SmParseError::PoundExpected
, pErrorDesc
->m_eType
);
282 void Test::ParseErrorColorExpected()
284 m_xDocShRef
->SetText(u
"color 42 x"_ustr
);
285 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
286 CPPUNIT_ASSERT(pErrorDesc
);
287 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::ColorExpected expected",
288 SmParseError::ColorExpected
, pErrorDesc
->m_eType
);
291 void Test::ParseErrorLgroupExpected()
293 m_xDocShRef
->SetText(u
"stack 42"_ustr
);
294 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
295 CPPUNIT_ASSERT(pErrorDesc
);
296 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::LgroupExpected expected",
297 SmParseError::LgroupExpected
, pErrorDesc
->m_eType
);
300 void Test::ParseErrorRgroupExpected()
302 m_xDocShRef
->SetText(u
"stack {a#b#c)"_ustr
);
303 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
304 CPPUNIT_ASSERT(pErrorDesc
);
305 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::RgroupExpected expected",
306 SmParseError::RgroupExpected
, pErrorDesc
->m_eType
);
309 void Test::ParseErrorLbraceExpected()
311 m_xDocShRef
->SetText(u
"left 42"_ustr
);
312 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
313 CPPUNIT_ASSERT(pErrorDesc
);
314 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::LbraceExpected expected",
315 SmParseError::LbraceExpected
, pErrorDesc
->m_eType
);
318 void Test::ParseErrorRbraceExpected()
320 m_xDocShRef
->SetText(u
"left ( foo right x"_ustr
);
321 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
322 CPPUNIT_ASSERT(pErrorDesc
);
323 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::RbraceExpected expected",
324 SmParseError::RbraceExpected
, pErrorDesc
->m_eType
);
327 void Test::ParseErrorParentMismatch()
329 m_xDocShRef
->SetText(u
"lbrace foo rceil"_ustr
);
330 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
331 CPPUNIT_ASSERT(pErrorDesc
);
332 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::ParentMismatch expected",
333 SmParseError::ParentMismatch
, pErrorDesc
->m_eType
);
336 void Test::ParseErrorRightExpected()
338 m_xDocShRef
->SetText(u
"left ( x mline y )"_ustr
);
339 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
340 CPPUNIT_ASSERT(pErrorDesc
);
341 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::RightExpected expected",
342 SmParseError::RightExpected
, pErrorDesc
->m_eType
);
345 void Test::ParseErrorFontExpected()
347 m_xDocShRef
->SetText(u
"font small bar"_ustr
);
348 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
349 CPPUNIT_ASSERT(pErrorDesc
);
350 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::FontExpected expected",
351 SmParseError::FontExpected
, pErrorDesc
->m_eType
);
354 void Test::ParseErrorSizeExpected()
356 m_xDocShRef
->SetText(u
"size small baz"_ustr
);
357 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
358 CPPUNIT_ASSERT(pErrorDesc
);
359 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::SizeExpected expected",
360 SmParseError::SizeExpected
, pErrorDesc
->m_eType
);
363 void Test::ParseErrorDoubleAlign()
365 m_xDocShRef
->SetText(u
"alignl alignc x"_ustr
);
366 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
367 CPPUNIT_ASSERT(pErrorDesc
);
368 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::DoubleAlign expected",
369 SmParseError::DoubleAlign
, pErrorDesc
->m_eType
);
372 void Test::ParseErrorDoubleSubsupscript()
374 m_xDocShRef
->SetText(u
"x_y_z"_ustr
);
375 const SmErrorDesc
*pErrorDesc
= m_xDocShRef
->GetParser()->NextError();
376 CPPUNIT_ASSERT(pErrorDesc
);
377 CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::DoubleSubsupscript expected",
378 SmParseError::DoubleSubsupscript
, pErrorDesc
->m_eType
);
381 void Test::editUndoRedo()
383 EditEngine
&rEditEngine
= m_xDocShRef
->GetEditEngine();
385 OUString
sStringOne(u
"a under b"_ustr
);
387 rEditEngine
.SetText(0, sStringOne
);
388 m_xDocShRef
->UpdateText();
389 OUString sFinalText
= m_xDocShRef
->GetText();
390 CPPUNIT_ASSERT_EQUAL_MESSAGE("Strings must match", sFinalText
, sStringOne
);
394 OUString
sStringTwo(u
"a over b"_ustr
);
395 rEditEngine
.SetText(0, sStringTwo
);
396 m_xDocShRef
->UpdateText();
397 OUString sFinalText
= m_xDocShRef
->GetText();
398 CPPUNIT_ASSERT_EQUAL_MESSAGE("Strings must match", sFinalText
, sStringTwo
);
401 SfxRequest
aUndo(SID_UNDO
, SfxCallMode::SYNCHRON
, SmDocShell::GetPool());
404 m_xDocShRef
->Execute(aUndo
);
405 m_xDocShRef
->UpdateText();
406 OUString sFinalText
= m_xDocShRef
->GetText();
407 CPPUNIT_ASSERT_EQUAL_MESSAGE("Strings much match", sFinalText
, sStringOne
);
411 m_xDocShRef
->Execute(aUndo
);
412 m_xDocShRef
->UpdateText();
413 OUString sFinalText
= m_xDocShRef
->GetText();
414 CPPUNIT_ASSERT_MESSAGE("Must now be empty", sFinalText
.isEmpty());
417 SfxRequest
aRedo(SID_REDO
, SfxCallMode::SYNCHRON
, SmDocShell::GetPool());
419 m_xDocShRef
->Execute(aRedo
);
420 m_xDocShRef
->UpdateText();
421 OUString sFinalText
= m_xDocShRef
->GetText();
422 CPPUNIT_ASSERT_EQUAL_MESSAGE("Strings much match", sFinalText
, sStringOne
);
426 rEditEngine
.SetText(0, OUString());
427 m_xDocShRef
->UpdateText();
428 rEditEngine
.ClearModifyFlag();
429 OUString sFinalText
= m_xDocShRef
->GetText();
430 CPPUNIT_ASSERT_MESSAGE("Must be empty", sFinalText
.isEmpty());
435 void Test::replacePlaceholder()
437 SmEditWindow
& rEditWindow
= m_pSmCmdBoxWindow
->GetEditWindow();
438 // Test the placeholder replacement. In this case, testing 'a + b', it
439 // should return '+a + b' when selecting '+<?>' in ElementsDock
440 rEditWindow
.SetText(u
"a + b"_ustr
);
441 rEditWindow
.SelectAll();
442 rEditWindow
.InsertText(u
"+<?>"_ustr
);
443 OUString sFinalText
= rEditWindow
.GetText();
444 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be '+a + b'", u
"+a + b"_ustr
, sFinalText
);
447 void Test::viewZoom()
449 sal_uInt16 nOrigZoom
, nFinalZoom
;
451 EditEngine
&rEditEngine
= m_xDocShRef
->GetEditEngine();
454 OUString
sStringOne(u
"a under b"_ustr
);
455 rEditEngine
.SetText(0, sStringOne
);
456 m_xDocShRef
->UpdateText();
457 OUString sFinalText
= m_xDocShRef
->GetText();
458 CPPUNIT_ASSERT_EQUAL_MESSAGE("Strings must match", sFinalText
, sStringOne
);
461 SmGraphicWindow
&rGraphicWindow
= m_pViewShell
->GetGraphicWindow();
462 rGraphicWindow
.SetSizePixel(Size(1024, 800));
463 nOrigZoom
= rGraphicWindow
.GetZoom();
466 SfxRequest
aZoomIn(SID_ZOOMIN
, SfxCallMode::SYNCHRON
, m_pViewShell
->GetPool());
467 m_pViewShell
->Execute(aZoomIn
);
468 sal_uInt16 nNextZoom
= rGraphicWindow
.GetZoom();
469 CPPUNIT_ASSERT_MESSAGE("Should be bigger", nNextZoom
> nOrigZoom
);
473 SfxRequest
aZoomOut(SID_ZOOMOUT
, SfxCallMode::SYNCHRON
, m_pViewShell
->GetPool());
474 m_pViewShell
->Execute(aZoomOut
);
475 nFinalZoom
= rGraphicWindow
.GetZoom();
476 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be equal", nOrigZoom
, nFinalZoom
);
479 sal_uInt16 nOptimalZoom
=0;
482 SfxRequest
aZoom(SID_ZOOM_OPTIMAL
, SfxCallMode::SYNCHRON
, m_pViewShell
->GetPool());
483 m_pViewShell
->Execute(aZoom
);
484 nOptimalZoom
= rGraphicWindow
.GetZoom();
485 CPPUNIT_ASSERT_MESSAGE("Should be about 800%", nOptimalZoom
> nOrigZoom
);
489 SfxItemSet
aSet(SmDocShell::GetPool(), svl::Items
<SID_ATTR_ZOOM
, SID_ATTR_ZOOM
>);
490 aSet
.Put(SvxZoomItem(SvxZoomType::OPTIMAL
, 0));
491 SfxRequest
aZoom(SID_ATTR_ZOOM
, SfxCallMode::SYNCHRON
, aSet
);
492 m_pViewShell
->Execute(aZoom
);
493 nFinalZoom
= rGraphicWindow
.GetZoom();
494 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be optimal zoom", nOptimalZoom
, nFinalZoom
);
497 //To-Do: investigate GetPrinter logic of SvxZoomType::PAGEWIDTH/SvxZoomType::WHOLEPAGE to ensure
498 //consistent value regardless of
501 SfxRequest
aZoomOut(SID_ZOOMOUT
, SfxCallMode::SYNCHRON
, m_pViewShell
->GetPool());
502 m_pViewShell
->Execute(aZoomOut
);
503 nFinalZoom
= rGraphicWindow
.GetZoom();
504 CPPUNIT_ASSERT_MESSAGE("Should not be optimal zoom", nFinalZoom
!= nOptimalZoom
);
506 SfxItemSet
aSet(m_xDocShRef
->GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
507 aSet
.Put(SvxZoomItem(SvxZoomType::PAGEWIDTH
, 0));
508 SfxRequest
aZoom(SID_ATTR_ZOOM
, SfxCallMode::SYNCHRON
, aSet
);
509 m_pViewShell
->Execute(aZoom
);
510 nFinalZoom
= rGraphicWindow
.GetZoom();
511 CPPUNIT_ASSERT_MESSAGE("Should be same as optimal zoom", nFinalZoom
== nOptimalZoom
);
515 SfxRequest
aZoomOut(SID_ZOOMOUT
, SfxCallMode::SYNCHRON
, m_pViewShell
->GetPool());
516 m_pViewShell
->Execute(aZoomOut
);
517 nFinalZoom
= rGraphicWindow
.GetZoom();
518 CPPUNIT_ASSERT_MESSAGE("Should not be optimal zoom", nFinalZoom
!= nOptimalZoom
);
520 SfxItemSet
aSet(m_xDocShRef
->GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
521 aSet
.Put(SvxZoomItem(SvxZoomType::WHOLEPAGE
, 0));
522 SfxRequest
aZoom(SID_ATTR_ZOOM
, SfxCallMode::SYNCHRON
, aSet
);
523 m_pViewShell
->Execute(aZoom
);
524 nFinalZoom
= rGraphicWindow
.GetZoom();
525 CPPUNIT_ASSERT_MESSAGE("Should be same as optimal zoom", nFinalZoom
== nOptimalZoom
);
530 SfxRequest
aZoomOut(SID_ZOOMOUT
, SfxCallMode::SYNCHRON
, m_pViewShell
->GetPool());
531 m_pViewShell
->Execute(aZoomOut
);
532 nFinalZoom
= rGraphicWindow
.GetZoom();
533 CPPUNIT_ASSERT_MESSAGE("Should not be optimal zoom", nFinalZoom
!= nOptimalZoom
);
535 SfxItemSet
aSet(SmDocShell::GetPool(), svl::Items
<SID_ATTR_ZOOM
, SID_ATTR_ZOOM
>);
536 aSet
.Put(SvxZoomItem(SvxZoomType::PERCENT
, 50));
537 SfxRequest
aZoom(SID_ATTR_ZOOM
, SfxCallMode::SYNCHRON
, aSet
);
538 m_pViewShell
->Execute(aZoom
);
539 nFinalZoom
= rGraphicWindow
.GetZoom();
540 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be 50%", static_cast<sal_uInt16
>(50), nFinalZoom
);
544 SfxItemSet
aSet(SmDocShell::GetPool(), svl::Items
<SID_ATTR_ZOOM
, SID_ATTR_ZOOM
>);
545 aSet
.Put(SvxZoomItem(SvxZoomType::PERCENT
, 5));
546 SfxRequest
aZoom(SID_ATTR_ZOOM
, SfxCallMode::SYNCHRON
, aSet
);
547 m_pViewShell
->Execute(aZoom
);
548 nFinalZoom
= rGraphicWindow
.GetZoom();
549 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be Clipped to 25%", static_cast<sal_uInt16
>(25), nFinalZoom
);
553 SfxItemSet
aSet(SmDocShell::GetPool(), svl::Items
<SID_ATTR_ZOOM
, SID_ATTR_ZOOM
>);
554 aSet
.Put(SvxZoomItem(SvxZoomType::PERCENT
, 1000));
555 SfxRequest
aZoom(SID_ATTR_ZOOM
, SfxCallMode::SYNCHRON
, aSet
);
556 m_pViewShell
->Execute(aZoom
);
557 nFinalZoom
= rGraphicWindow
.GetZoom();
558 CPPUNIT_ASSERT_EQUAL_MESSAGE("Should be Clipped to 800%", static_cast<sal_uInt16
>(800), nFinalZoom
);
563 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
567 CPPUNIT_PLUGIN_IMPLEMENT();
569 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */