|
|
f325b2 |
From 8e7c77d0706c4a2870de61948364667b575ff027 Mon Sep 17 00:00:00 2001
|
|
|
f325b2 |
From: Jan Holesovsky <kendy@collabora.com>
|
|
|
f325b2 |
Date: Tue, 3 Nov 2015 16:43:03 +0100
|
|
|
f325b2 |
Subject: [PATCH 270/398] lok: Unit test for LOK_CALLBACK_UNO_COMMAND_RESULT.
|
|
|
f325b2 |
|
|
|
f325b2 |
Change-Id: I917d47478504dc6fafd3fc675fe8458690c7cc2a
|
|
|
f325b2 |
(cherry picked from commit a4988d227c3933721098b2a61a087ec18eaa6c8e)
|
|
|
f325b2 |
---
|
|
|
f325b2 |
desktop/qa/desktop_lib/test_desktop_lib.cxx | 36 +++++++++++++++++++++++++++++
|
|
|
f325b2 |
1 file changed, 36 insertions(+)
|
|
|
f325b2 |
|
|
|
f325b2 |
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
|
|
|
f325b2 |
index 29b0aedd4dfa..15fe123fdc37 100644
|
|
|
f325b2 |
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
|
|
|
f325b2 |
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
|
|
|
f325b2 |
@@ -19,6 +19,7 @@
|
|
|
f325b2 |
#include <comphelper/lok.hxx>
|
|
|
f325b2 |
#include <comphelper/dispatchcommand.hxx>
|
|
|
f325b2 |
#include <comphelper/propertysequence.hxx>
|
|
|
f325b2 |
+#include <osl/conditn.hxx>
|
|
|
f325b2 |
#include <svl/srchitem.hxx>
|
|
|
f325b2 |
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
|
|
f325b2 |
#include <unotools/tempfile.hxx>
|
|
|
f325b2 |
@@ -67,6 +68,7 @@ public:
|
|
|
f325b2 |
void testSaveAsCalc();
|
|
|
f325b2 |
void testPasteWriter();
|
|
|
f325b2 |
void testRowColumnHeaders();
|
|
|
f325b2 |
+ void testCommandResult();
|
|
|
f325b2 |
|
|
|
f325b2 |
CPPUNIT_TEST_SUITE(DesktopLOKTest);
|
|
|
f325b2 |
CPPUNIT_TEST(testGetStyles);
|
|
|
f325b2 |
@@ -80,12 +82,17 @@ public:
|
|
|
f325b2 |
CPPUNIT_TEST(testSaveAsCalc);
|
|
|
f325b2 |
CPPUNIT_TEST(testPasteWriter);
|
|
|
f325b2 |
CPPUNIT_TEST(testRowColumnHeaders);
|
|
|
f325b2 |
+ CPPUNIT_TEST(testCommandResult);
|
|
|
f325b2 |
CPPUNIT_TEST_SUITE_END();
|
|
|
f325b2 |
|
|
|
f325b2 |
uno::Reference<lang::XComponent> mxComponent;
|
|
|
f325b2 |
OString m_aTextSelection;
|
|
|
f325b2 |
std::vector<OString> m_aSearchResultSelection;
|
|
|
f325b2 |
std::vector<int> m_aSearchResultPart;
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ // for testCommandResult
|
|
|
f325b2 |
+ osl::Condition m_aCommandResultCondition;
|
|
|
f325b2 |
+ OString m_aCommandResult;
|
|
|
f325b2 |
};
|
|
|
f325b2 |
|
|
|
f325b2 |
LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
|
|
|
f325b2 |
@@ -149,6 +156,12 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
|
|
|
f325b2 |
}
|
|
|
f325b2 |
}
|
|
|
f325b2 |
break;
|
|
|
f325b2 |
+ case LOK_CALLBACK_UNO_COMMAND_RESULT:
|
|
|
f325b2 |
+ {
|
|
|
f325b2 |
+ m_aCommandResult = pPayload;
|
|
|
f325b2 |
+ m_aCommandResultCondition.set();
|
|
|
f325b2 |
+ }
|
|
|
f325b2 |
+ break;
|
|
|
f325b2 |
}
|
|
|
f325b2 |
}
|
|
|
f325b2 |
|
|
|
f325b2 |
@@ -378,6 +391,29 @@ void DesktopLOKTest::testRowColumnHeaders()
|
|
|
f325b2 |
}
|
|
|
f325b2 |
}
|
|
|
f325b2 |
|
|
|
f325b2 |
+void DesktopLOKTest::testCommandResult()
|
|
|
f325b2 |
+{
|
|
|
f325b2 |
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
|
|
|
f325b2 |
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ // the postUnoCommand() is supposed to be async, let's test it safely
|
|
|
f325b2 |
+ // [no idea if it is async in reality - most probably we are operating
|
|
|
f325b2 |
+ // under some solar mutex or something anyway ;-) - but...]
|
|
|
f325b2 |
+ m_aCommandResultCondition.reset();
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true);
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max
|
|
|
f325b2 |
+ m_aCommandResultCondition.wait(aTimeValue);
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ boost::property_tree::ptree aTree;
|
|
|
f325b2 |
+ std::stringstream aStream(m_aCommandResult.getStr());
|
|
|
f325b2 |
+ boost::property_tree::read_json(aStream, aTree);
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ CPPUNIT_ASSERT_EQUAL(aTree.get_child("commandName").get_value<std::string>(), std::string(".uno:Bold"));
|
|
|
f325b2 |
+ CPPUNIT_ASSERT_EQUAL(aTree.get_child("success").get_value<bool>(), true);
|
|
|
f325b2 |
+}
|
|
|
f325b2 |
+
|
|
|
f325b2 |
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
|
|
|
f325b2 |
|
|
|
f325b2 |
CPPUNIT_PLUGIN_IMPLEMENT();
|
|
|
f325b2 |
--
|
|
|
f325b2 |
2.12.0
|
|
|
f325b2 |
|