diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-14 16:59:01 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-14 17:28:33 +0100 |
commit | 1118689e70ed49604ded6e1ae83a22bdc995b2fb (patch) | |
tree | d69570ceb2fef653e9aa5f516a3aaa78331ebab1 /desktop/qa | |
parent | 18dfcbb11a05b7e702dc2161df9db8386a7ca34b (diff) |
CppunitTest_desktop_lib: add Writer comments textcase
Fails without e.g. the last hunk of commit
1ba9d7fd2a7a3e2b4f52ed0f5efdf7df867b9db3 (sw lok: forward key events to
annotation window if necessary, 2015-11-12).
Change-Id: I7f39530881f6141fea956b751aa57eb2bdcadcb2
Diffstat (limited to 'desktop/qa')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 21e177a490a6..5ca573d12185 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -10,6 +10,10 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/XReschedule.hpp> +#include <com/sun/star/awt/Toolkit.hpp> #include <boost/property_tree/json_parser.hpp> #include <comphelper/processfactory.hxx> @@ -70,6 +74,7 @@ public: void testRowColumnHeaders(); void testCellCursor(); void testCommandResult(); + void testWriterComments(); CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST(testGetStyles); @@ -85,6 +90,7 @@ public: CPPUNIT_TEST(testRowColumnHeaders); CPPUNIT_TEST(testCellCursor); CPPUNIT_TEST(testCommandResult); + CPPUNIT_TEST(testWriterComments); CPPUNIT_TEST_SUITE_END(); uno::Reference<lang::XComponent> mxComponent; @@ -491,6 +497,46 @@ void DesktopLOKTest::testCommandResult() CPPUNIT_ASSERT_EQUAL(aTree.get_child("success").get_value<bool>(), true); } +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); + + // Insert a comment at the beginning of the document and wait till the main + // loop grabs the focus, so characters end up in the annotation window. + TimeValue aTimeValue = {2 , 0}; // 2 seconds max + m_aCommandResultCondition.reset(); + pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", nullptr, true); + m_aCommandResultCondition.wait(aTimeValue); + CPPUNIT_ASSERT(!m_aCommandResult.isEmpty()); + xToolkit->reschedule(); + + // Test that we have a comment. + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParagraphEnumeration = xParagraphEnumerationAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphEnumeration->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xTextPortionEnumeration = xParagraph->createEnumeration(); + uno::Reference<beans::XPropertySet> xTextPortion(xTextPortionEnumeration->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), xTextPortion->getPropertyValue("TextPortionType").get<OUString>()); + + // Type "test" and finish editing. + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'e', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 's', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0); + pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, com::sun::star::awt::Key::ESCAPE); + + // Test that the typed characters ended up in the right window. + auto xTextField = xTextPortion->getPropertyValue("TextField").get< uno::Reference<beans::XPropertySet> >(); + // This was empty, typed characters ended up in the body text. + CPPUNIT_ASSERT_EQUAL(OUString("test"), xTextField->getPropertyValue("Content").get<OUString>()); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); CPPUNIT_PLUGIN_IMPLEMENT(); |