diff options
Diffstat (limited to 'desktop/qa/desktop_lib/test_desktop_lib.cxx')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 83 |
1 files changed, 79 insertions, 4 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 3a95e96dbda5..2a995277081a 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -282,6 +282,7 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload) void DesktopLOKTest::testGetStyles() { + comphelper::LibreOfficeKit::setActive(); LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); boost::property_tree::ptree aTree; char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:StyleApply"); @@ -311,6 +312,7 @@ void DesktopLOKTest::testGetStyles() CPPUNIT_FAIL("Unknown style family: " + rPair.first); } } + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testGetFonts() @@ -337,6 +339,7 @@ void DesktopLOKTest::testGetFonts() void DesktopLOKTest::testCreateView() { + comphelper::LibreOfficeKit::setActive(); LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument)); @@ -358,10 +361,12 @@ void DesktopLOKTest::testCreateView() pDocument->m_pDocumentClass->destroyView(pDocument, nId1); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument)); + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testGetPartPageRectangles() { + comphelper::LibreOfficeKit::setActive(); // Test that we get as many page rectangles as expected: blank document is // one page. LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); @@ -380,10 +385,12 @@ void DesktopLOKTest::testGetPartPageRectangles() CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aRectangles.size()); free(pRectangles); + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testGetFilterTypes() { + comphelper::LibreOfficeKit::setActive(); LibLibreOffice_Impl aOffice; char* pJSON = aOffice.m_pOfficeClass->getFilterTypes(&aOffice); @@ -394,12 +401,14 @@ void DesktopLOKTest::testGetFilterTypes() CPPUNIT_ASSERT(aTree.size() > 0); CPPUNIT_ASSERT_EQUAL(std::string("application/vnd.oasis.opendocument.text"), aTree.get_child("writer8").get_child("MediaType").get_value<std::string>()); free(pJSON); + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testSearchCalc() { - LibLibreOffice_Impl aOffice; comphelper::LibreOfficeKit::setActive(); + + LibLibreOffice_Impl aOffice; LibLODocument_Impl* pDocument = loadDoc("search.ods"); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); @@ -432,8 +441,9 @@ void DesktopLOKTest::testSearchCalc() void DesktopLOKTest::testSearchAllNotificationsCalc() { - LibLibreOffice_Impl aOffice; comphelper::LibreOfficeKit::setActive(); + + LibLibreOffice_Impl aOffice; LibLODocument_Impl* pDocument = loadDoc("search.ods"); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); @@ -457,6 +467,8 @@ void DesktopLOKTest::testSearchAllNotificationsCalc() void DesktopLOKTest::testPaintTile() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); int nCanvasWidth = 100; int nCanvasHeight = 300; @@ -479,27 +491,38 @@ void DesktopLOKTest::testPaintTile() nTileHeight = 4000; aBuffer.resize(nCanvasWidth * nCanvasHeight * 4); pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testSaveAs() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); utl::TempFile aTempFile; aTempFile.EnableKillingFile(); CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr)); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testSaveAsCalc() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("search.ods"); utl::TempFile aTempFile; aTempFile.EnableKillingFile(); CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr)); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testPasteWriter() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); OString aText("hello"); @@ -521,6 +544,7 @@ void DesktopLOKTest::testPasteWriter() void DesktopLOKTest::testPasteWriterJPEG() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); OUString aFileURL; @@ -557,6 +581,7 @@ void DesktopLOKTest::testUndoWriter() { // Load a Writer document and press a key. comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0); pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 't', 0); @@ -605,6 +630,8 @@ void DesktopLOKTest::testRowColumnHeaders() * "size" defines the bottom/right boundary of a row/column in twips (size between 0 and boundary) * "text" has the header label in UTF-8 */ + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("search.ods"); pDocument->pClass->initializeForRendering(pDocument, nullptr); @@ -682,10 +709,14 @@ void DesktopLOKTest::testRowColumnHeaders() nPrevious = nSize; } CPPUNIT_ASSERT(!bNotEnoughHeaders); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testHiddenRowHeaders() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("hidden-row.ods"); pDocument->pClass->initializeForRendering(pDocument, nullptr); @@ -720,10 +751,13 @@ void DesktopLOKTest::testHiddenRowHeaders() } nPrevious = nSize; } + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testCellCursor() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("search.ods"); boost::property_tree::ptree aTree; @@ -738,10 +772,14 @@ void DesktopLOKTest::testCellCursor() OString aRectangle(aTree.get<std::string>("commandValues").c_str()); CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1279, 255"), aRectangle); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testCommandResult() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); // the postUnoCommand() is supposed to be async, let's test it safely @@ -772,11 +810,14 @@ void DesktopLOKTest::testCommandResult() CPPUNIT_ASSERT_EQUAL(aTree.get_child("commandName").get_value<std::string>(), std::string(".uno:Bold")); CPPUNIT_ASSERT_EQUAL(aTree.get_child("success").get_value<bool>(), true); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testWriterComments() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); uno::Reference<awt::XReschedule> xToolkit(com::sun::star::awt::Toolkit::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY); @@ -817,9 +858,10 @@ void DesktopLOKTest::testWriterComments() void DesktopLOKTest::testTrackChanges() { + comphelper::LibreOfficeKit::setActive(); + // Load a document and create two views. LibLibreOffice_Impl aOffice; - comphelper::LibreOfficeKit::setActive(); LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); @@ -841,6 +883,7 @@ void DesktopLOKTest::testTrackChanges() void DesktopLOKTest::testSheetOperations() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("sheets.ods"); // insert the last sheet @@ -873,6 +916,7 @@ void DesktopLOKTest::testSheetOperations() void DesktopLOKTest::testSheetSelections() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); @@ -1053,6 +1097,7 @@ namespace { void DesktopLOKTest::testContextMenuCalc() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("sheet_with_image.ods", LOK_DOCTYPE_SPREADSHEET); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); @@ -1164,6 +1209,7 @@ void DesktopLOKTest::testContextMenuCalc() void DesktopLOKTest::testContextMenuWriter() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); @@ -1220,6 +1266,7 @@ void DesktopLOKTest::testContextMenuWriter() void DesktopLOKTest::testContextMenuImpress() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_presentation.odp", LOK_DOCTYPE_PRESENTATION); pDocument->pClass->initializeForRendering(pDocument, nullptr); pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); @@ -1351,6 +1398,8 @@ static void callbackCompressionTest(const int type, const char* payload, void* d void DesktopLOKTest::testNotificationCompression() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); std::vector<std::tuple<int, std::string>> notifs; std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackCompressionTest, ¬ifs)); @@ -1433,10 +1482,14 @@ void DesktopLOKTest::testNotificationCompression() CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL(std::string(".uno:AssignLayout=1"), std::get<1>(notifs[i++])); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testTileInvalidationCompression() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); comphelper::LibreOfficeKit::setPartInInvalidation(true); @@ -1568,10 +1621,14 @@ void DesktopLOKTest::testTileInvalidationCompression() CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 1000000000, 1000000000, 0"), std::get<1>(notifs[i++])); } + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testPartInInvalidation() { + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); // No part in invalidation: merge. { @@ -1639,12 +1696,15 @@ void DesktopLOKTest::testPartInInvalidation() // payload, so this was merged -> it was 1. CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), notifs.size()); } + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testRedlineWriter() { - // Load a Writer document, enable change recording and press a key. comphelper::LibreOfficeKit::setActive(); + + // Load a Writer document, enable change recording and press a key. LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY); xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true)); @@ -1674,6 +1734,7 @@ void DesktopLOKTest::testRedlineCalc() { // Load a Writer document, enable change recording and press a key. comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("sheets.ods"); uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY); xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true)); @@ -1754,6 +1815,7 @@ void DesktopLOKTest::testPaintPartTile() { // Load an impress doc of 2 slides. comphelper::LibreOfficeKit::setActive(); + ViewCallback aView1; ViewCallback aView2; std::unique_ptr<LibLODocument_Impl> xDocument(loadDoc("2slides.odp")); @@ -1793,6 +1855,7 @@ void DesktopLOKTest::testPaintPartTile() Scheduler::ProcessEventsToIdle(); mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); } @@ -1800,6 +1863,7 @@ void DesktopLOKTest::testWriterCommentInsertCursor() { // Load a document and type a character into the body text of the second view. comphelper::LibreOfficeKit::setActive(); + ViewCallback aView1; ViewCallback aView2; std::unique_ptr<LibLODocument_Impl> xDocument(loadDoc("blank_text.odt")); @@ -1833,6 +1897,7 @@ void DesktopLOKTest::testWriterCommentInsertCursor() Scheduler::ProcessEventsToIdle(); mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); } @@ -1840,6 +1905,7 @@ void DesktopLOKTest::testWriterCommentInsertCursor() void DesktopLOKTest::testGetFontSubset() { comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); OUString aFontName = rtl::Uri::encode( OUString("Liberation Sans"), @@ -1857,6 +1923,7 @@ void DesktopLOKTest::testGetFontSubset() boost::property_tree::ptree aValues = aTree.get_child("commandValues"); CPPUNIT_ASSERT( aValues.size() > 0 ); free(pJSON); + comphelper::LibreOfficeKit::setActive(false); } #endif @@ -2114,6 +2181,8 @@ void DesktopLOKTest::testCommentsCallbacksWriter() void DesktopLOKTest::testRunMacro() { + comphelper::LibreOfficeKit::setActive(); + LibLibreOffice_Impl aOffice; bool bGoodMacro, bNonExistentMacro; @@ -2123,10 +2192,14 @@ void DesktopLOKTest::testRunMacro() bNonExistentMacro = aOffice.m_pOfficeClass->runMacro(&aOffice, OString("macro:///I.Am.Not(There)").getStr()); CPPUNIT_ASSERT(!bNonExistentMacro); + + comphelper::LibreOfficeKit::setActive(false); } void DesktopLOKTest::testExtractParameter() { + comphelper::LibreOfficeKit::setActive(); + OUString aOptions("Language=de-DE"); OUString aValue = extractParameter(aOptions, "Language"); CPPUNIT_ASSERT_EQUAL(OUString("de-DE"), aValue); @@ -2151,6 +2224,8 @@ void DesktopLOKTest::testExtractParameter() aValue = extractParameter(aOptions, "Language"); CPPUNIT_ASSERT_EQUAL(OUString(), aValue); CPPUNIT_ASSERT_EQUAL(OUString("Something1,Something2=blah,Something3"), aOptions); + + comphelper::LibreOfficeKit::setActive(false); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); |