Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
e1832340
Commit
e1832340
authored
Sep 08, 2010
by
Alexandre Savard
Browse files
[#3963] Implements unit test to retreive message and uri-list in instant message
parent
7558f283
Changes
3
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/sip/im/InstantMessaging.cpp
View file @
e1832340
...
...
@@ -311,9 +311,9 @@ std::string InstantMessaging::findTextUriList (std::string text)
size_t
begin
=
pos
+
cdispo
.
size
();
size_t
end
=
text
.
find
(
"--boundary
1
--"
,
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
);
}
...
...
sflphone-common/test/instantmessagingtest.cpp
View file @
e1832340
...
...
@@ -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
\n
Content-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
\n
Content-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
;
...
...
sflphone-common/test/instantmessagingtest.h
View file @
e1832340
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment