test/httpwstest.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
New commits: commit d31e0e3aacfa31990f43d68a39ff43f2203036bc Author: Henry Castro <hcas...@collabora.com> Date: Tue May 30 22:26:05 2017 -0400 wsd: test: undo conflict Change-Id: Iafdcf3e206a425b7e55cca7818beb620e9d06f85 diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp index 5d80f40e..3df78569 100644 --- a/test/httpwstest.cpp +++ b/test/httpwstest.cpp @@ -107,6 +107,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(testCursorPosition); CPPUNIT_TEST(testAlertAllUsers); CPPUNIT_TEST(testViewInfoMsg); + CPPUNIT_TEST(testUndoConflict); CPPUNIT_TEST_SUITE_END(); @@ -163,6 +164,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture void testCursorPosition(); void testAlertAllUsers(); void testViewInfoMsg(); + void testUndoConflict(); void loadDoc(const std::string& documentURL, const std::string& testname); @@ -2601,6 +2603,55 @@ void HTTPWSTest::testViewInfoMsg() } } +void HTTPWSTest::testUndoConflict() +{ + const std::string testname = "testUndoConflict-"; + Poco::JSON::Parser parser; + std::string docPath; + std::string docURL; + int conflict; + + getDocumentPathAndURL("empty.odt", docPath, docURL, testname); + + Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, docURL); + auto socket0 = connectLOKit(_uri, request, _response); + auto socket1 = connectLOKit(_uri, request, _response); + + std::string response; + try + { + // Load first view + sendTextFrame(socket0, "load url=" + docURL); + response = getResponseString(socket0, "invalidatecursor:", testname + "0 "); + + // Load second view + sendTextFrame(socket1, "load url=" + docURL); + response = getResponseString(socket1, "invalidatecursor:", testname + "1 "); + + // edit first view + sendTextFrame(socket0, "key type=input char=97 key=0", testname); + response = getResponseString(socket0, "invalidatecursor:", testname + "0 "); + // edit second view + sendTextFrame(socket1, "key type=input char=98 key=0", testname); + response = getResponseString(socket1, "invalidatecursor:", testname + "1 "); + // try to undo first view + sendTextFrame(socket0, "uno .uno:Undo", testname); + // undo conflict + response = getResponseString(socket0, "unocommandresult:", testname + "0 "); + auto objJSON = parser.parse(response.substr(17)).extract<Poco::JSON::Object::Ptr>(); + Poco::DynamicStruct dsJSON = *objJSON; + CPPUNIT_ASSERT_EQUAL(dsJSON["commandName"].toString(), std::string(".uno:Undo")); + CPPUNIT_ASSERT_EQUAL(dsJSON["success"].toString(), std::string("true")); + CPPUNIT_ASSERT_EQUAL(dsJSON["result"]["type"].toString(), std::string("long")); + CPPUNIT_ASSERT(Poco::strToInt(dsJSON["result"]["value"].toString(), conflict, 10)); + CPPUNIT_ASSERT(conflict > 0); /*UNDO_CONFLICT*/ + } + catch(const Poco::Exception& exc) + { + CPPUNIT_FAIL(exc.displayText()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(HTTPWSTest); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits