Commit e1832340 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3963] Implements unit test to retreive message and uri-list in instant message

parent 7558f283
......@@ -311,9 +311,9 @@ std::string InstantMessaging::findTextUriList (std::string text)
size_t begin = pos+cdispo.size();
size_t end = text.find ("--boundary1--", begin);
size_t end = text.find ("--boundary--", begin);
return text.substr (begin, end);
return text.substr (begin, end-begin);
}
std::string InstantMessaging::findTextMessage (std::string text)
......@@ -327,7 +327,7 @@ std::string InstantMessaging::findTextMessage (std::string text)
size_t end = text.find (boundary, begin);
return text.substr (begin, end);
return text.substr (begin, end-begin);
}
......
......@@ -265,6 +265,51 @@ void InstantMessagingTest::testXmlUriListParsing ()
}
}
void InstantMessagingTest::testGetTextArea ()
{
std::string formatedText = "--boundary\n Content-Type: text/plain\n\n";
formatedText.append ("Here is the text area");
formatedText.append ("\n--boundary\nContent-Type: application/resource-lists+xml\n");
formatedText.append ("Content-Disposition: recipient-list\n\n");
formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">");
formatedText.append ("<list>");
formatedText.append ("<entry uri=\"sip:alex@example.com\" cp:copyControl=\"to\" />");
formatedText.append ("<entry uri=\"sip:manu@example.com\" cp:copyControl=\"to\" />");
formatedText.append ("</list>");
formatedText.append ("</resource-lists>");
formatedText.append ("--boundary--");
std::string message = _im->findTextMessage(formatedText);
std::cout << "message: " << message << std::endl;
}
void InstantMessagingTest::testGetUriListArea ()
{
std::string formatedText = "--boundary\n Content-Type: text/plain\n\n";
formatedText.append ("Here is the text area");
formatedText.append ("\n--boundary\nContent-Type: application/resource-lists+xml\n");
formatedText.append ("Content-Disposition: recipient-list\n\n");
formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">");
formatedText.append ("<list>");
formatedText.append ("<entry uri=\"sip:alex@example.com\" cp:copyControl=\"to\" />");
formatedText.append ("<entry uri=\"sip:manu@example.com\" cp:copyControl=\"to\" />");
formatedText.append ("</list>");
formatedText.append ("</resource-lists>");
formatedText.append ("--boundary--");
std::string urilist = _im->findTextUriList(formatedText);
std::cout << "urilist: " << urilist << std::endl;
}
void InstantMessagingTest::tearDown()
{
delete _im;
......
......@@ -58,6 +58,8 @@ class InstantMessagingTest : public CppUnit::TestCase {
CPPUNIT_TEST (testSplitMessage);
CPPUNIT_TEST (testGenerateXmlUriList);
CPPUNIT_TEST (testXmlUriListParsing);
CPPUNIT_TEST (testGetTextArea);
CPPUNIT_TEST (testGetUriListArea);
CPPUNIT_TEST_SUITE_END();
public:
......@@ -84,6 +86,10 @@ class InstantMessagingTest : public CppUnit::TestCase {
void testGenerateXmlUriList ();
void testXmlUriListParsing ();
void testGetTextArea ();
void testGetUriListArea ();
private:
sfl::InstantMessaging *_im;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment