Blame SOURCES/0335-CppunitTest_desktop_lib-add-Writer-comments-textcase.patch

f325b2
From a779115ee56769b7691b02e4b8739c5c8f81258e Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Sat, 14 Nov 2015 16:59:01 +0100
f325b2
Subject: [PATCH 335/398] CppunitTest_desktop_lib: add Writer comments textcase
f325b2
f325b2
Fails without e.g. the last hunk of commit
f325b2
1ba9d7fd2a7a3e2b4f52ed0f5efdf7df867b9db3 (sw lok: forward key events to
f325b2
annotation window if necessary, 2015-11-12).
f325b2
f325b2
Change-Id: I7f39530881f6141fea956b751aa57eb2bdcadcb2
f325b2
(cherry picked from commit 1118689e70ed49604ded6e1ae83a22bdc995b2fb)
f325b2
---
f325b2
 desktop/CppunitTest_desktop_lib.mk          |  1 +
f325b2
 desktop/qa/desktop_lib/test_desktop_lib.cxx | 46 +++++++++++++++++++++++++++++
f325b2
 2 files changed, 47 insertions(+)
f325b2
f325b2
diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk
f325b2
index ca9d8db32c9f..bbedfdc8348e 100644
f325b2
--- a/desktop/CppunitTest_desktop_lib.mk
f325b2
+++ b/desktop/CppunitTest_desktop_lib.mk
f325b2
@@ -67,6 +67,7 @@ $(eval $(call gb_CppunitTest_use_components,desktop_lib,\
f325b2
     xmloff/util/xo \
f325b2
     i18npool/source/search/i18nsearch \
f325b2
     filter/source/graphic/graphicfilter \
f325b2
+    linguistic/source/lng \
f325b2
 ))
f325b2
 
f325b2
 $(eval $(call gb_CppunitTest_use_configuration,desktop_lib))
f325b2
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
index 7d94daea0fbc..930dd21ec081 100644
f325b2
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
f325b2
@@ -10,6 +10,10 @@
f325b2
 #include <com/sun/star/frame/Desktop.hpp>
f325b2
 #include <com/sun/star/lang/XComponent.hpp>
f325b2
 #include <com/sun/star/frame/XComponentLoader.hpp>
f325b2
+#include <com/sun/star/text/XTextDocument.hpp>
f325b2
+#include <com/sun/star/awt/Key.hpp>
f325b2
+#include <com/sun/star/awt/XReschedule.hpp>
f325b2
+#include <com/sun/star/awt/Toolkit.hpp>
f325b2
 
f325b2
 #include <boost/property_tree/json_parser.hpp>
f325b2
 #include <comphelper/processfactory.hxx>
f325b2
@@ -70,6 +74,7 @@ public:
f325b2
     void testRowColumnHeaders();
f325b2
     void testCellCursor();
f325b2
     void testCommandResult();
f325b2
+    void testWriterComments();
f325b2
 
f325b2
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
f325b2
     CPPUNIT_TEST(testGetStyles);
f325b2
@@ -85,6 +90,7 @@ public:
f325b2
     CPPUNIT_TEST(testRowColumnHeaders);
f325b2
     CPPUNIT_TEST(testCellCursor);
f325b2
     CPPUNIT_TEST(testCommandResult);
f325b2
+    CPPUNIT_TEST(testWriterComments);
f325b2
     CPPUNIT_TEST_SUITE_END();
f325b2
 
f325b2
     uno::Reference<lang::XComponent> mxComponent;
f325b2
@@ -491,6 +497,46 @@ void DesktopLOKTest::testCommandResult()
f325b2
     CPPUNIT_ASSERT_EQUAL(aTree.get_child("success").get_value<bool>(), true);
f325b2
 }
f325b2
 
f325b2
+void DesktopLOKTest::testWriterComments()
f325b2
+{
f325b2
+    comphelper::LibreOfficeKit::setActive();
f325b2
+    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
f325b2
+    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
f325b2
+    uno::Reference<awt::XReschedule> xToolkit(com::sun::star::awt::Toolkit::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY);
f325b2
+
f325b2
+    // Insert a comment at the beginning of the document and wait till the main
f325b2
+    // loop grabs the focus, so characters end up in the annotation window.
f325b2
+    TimeValue aTimeValue = {2 , 0}; // 2 seconds max
f325b2
+    m_aCommandResultCondition.reset();
f325b2
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", nullptr, true);
f325b2
+    m_aCommandResultCondition.wait(aTimeValue);
f325b2
+    CPPUNIT_ASSERT(!m_aCommandResult.isEmpty());
f325b2
+    xToolkit->reschedule();
f325b2
+
f325b2
+    // Test that we have a comment.
f325b2
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
f325b2
+    uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(xTextDocument->getText(), uno::UNO_QUERY);
f325b2
+    uno::Reference<container::XEnumeration> xParagraphEnumeration = xParagraphEnumerationAccess->createEnumeration();
f325b2
+    uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphEnumeration->nextElement(), uno::UNO_QUERY);
f325b2
+    uno::Reference<container::XEnumeration> xTextPortionEnumeration = xParagraph->createEnumeration();
f325b2
+    uno::Reference<beans::XPropertySet> xTextPortion(xTextPortionEnumeration->nextElement(), uno::UNO_QUERY);
f325b2
+    CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), xTextPortion->getPropertyValue("TextPortionType").get<OUString>());
f325b2
+
f325b2
+    // Type "test" and finish editing.
f325b2
+    pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
f325b2
+    pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'e', 0);
f325b2
+    pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 's', 0);
f325b2
+    pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
f325b2
+    pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, com::sun::star::awt::Key::ESCAPE);
f325b2
+
f325b2
+    // Test that the typed characters ended up in the right window.
f325b2
+    auto xTextField = xTextPortion->getPropertyValue("TextField").get< uno::Reference<beans::XPropertySet> >();
f325b2
+    // This was empty, typed characters ended up in the body text.
f325b2
+    CPPUNIT_ASSERT_EQUAL(OUString("test"), xTextField->getPropertyValue("Content").get<OUString>());
f325b2
+
f325b2
+    comphelper::LibreOfficeKit::setActive(false);
f325b2
+}
f325b2
+
f325b2
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
f325b2
 
f325b2
 CPPUNIT_PLUGIN_IMPLEMENT();
f325b2
-- 
f325b2
2.12.0
f325b2