test: improve getAllText to match an expected payload
Change-Id: I4159f1e21f581ccdf90bcacf489580c8887931e5 Reviewed-on: https://gerrit.libreoffice.org/81195 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com> (cherry picked from commit 9903229918d07eee2f6c1ad22ee5a287f4fd0884) Reviewed-on: https://gerrit.libreoffice.org/81571 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
parent
0b9bc00817
commit
d6306c5388
2 changed files with 15 additions and 8 deletions
|
@ -729,20 +729,26 @@ inline void deleteAll(const std::shared_ptr<LOOLWebSocket>& socket, const std::s
|
|||
}
|
||||
|
||||
inline std::string getAllText(const std::shared_ptr<LOOLWebSocket>& socket,
|
||||
const std::string& testname, int retry = COMMAND_RETRY_COUNT)
|
||||
const std::string& testname,
|
||||
const std::string expected = std::string(),
|
||||
int retry = COMMAND_RETRY_COUNT)
|
||||
{
|
||||
std::string text;
|
||||
static const std::string prefix = "textselectioncontent: ";
|
||||
|
||||
for (int i = 0; i < retry; ++i)
|
||||
{
|
||||
selectAll(socket, testname);
|
||||
|
||||
sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8", testname);
|
||||
text = assertResponseString(socket, "textselectioncontent:", testname);
|
||||
const std::string text = getResponseString(socket, prefix, testname);
|
||||
if (!text.empty())
|
||||
break;
|
||||
{
|
||||
if (expected.empty() || (prefix + expected) == text)
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -515,8 +515,9 @@ void HTTPWSTest::testGetTextSelection()
|
|||
std::shared_ptr<LOOLWebSocket> socket = loadDocAndGetSocket(_uri, documentURL, testname);
|
||||
std::shared_ptr<LOOLWebSocket> socket2 = loadDocAndGetSocket(_uri, documentURL, testname);
|
||||
|
||||
const std::string selection = getAllText(socket, testname);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("textselectioncontent: Hello world"), selection);
|
||||
static const std::string expected = "Hello world";
|
||||
const std::string selection = getAllText(socket, testname, expected);
|
||||
CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + expected, selection);
|
||||
}
|
||||
catch (const Poco::Exception& exc)
|
||||
{
|
||||
|
@ -580,7 +581,7 @@ void HTTPWSTest::testSaveOnDisconnect()
|
|||
CPPUNIT_ASSERT_EQUAL(kitcount, countLoolKitProcesses(kitcount));
|
||||
|
||||
// Check if the document contains the pasted text.
|
||||
const std::string selection = getAllText(socket, testname);
|
||||
const std::string selection = getAllText(socket, testname, text);
|
||||
CPPUNIT_ASSERT_EQUAL("textselectioncontent: " + text, selection);
|
||||
}
|
||||
catch (const Poco::Exception& exc)
|
||||
|
|
Loading…
Reference in a new issue