Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1643)

Unified Diff: remoting/protocol/jingle_messages_unittest.cc

Issue 2567953002: [Chromoting] Plugin message in JingleMessage (Closed)
Patch Set: Add OWNERS file to work around IPC security check Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/jingle_messages_unittest.cc
diff --git a/remoting/protocol/jingle_messages_unittest.cc b/remoting/protocol/jingle_messages_unittest.cc
index a72db8636103c769892e8cdfd34a69d434511613..3f3349ba5384ed4117e7722c7bb16a69ce03cdcd 100644
--- a/remoting/protocol/jingle_messages_unittest.cc
+++ b/remoting/protocol/jingle_messages_unittest.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/strings/string_util.h"
#include "remoting/protocol/content_description.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -600,5 +601,70 @@ TEST(JingleMessageTest, RemotingErrorCode) {
}
}
+TEST(JingleMessageTest, AttachmentsMessage) {
+ // Ordering of the "attachments" tag and other tags are irrelevent. But the
+ // JingleMessage implementation always puts it before other tags, so we do the
+ // same thing in test cases.
+ const char* kMessageWithPluginTag =
+ "<cli:iq from='user@gmail.com/chromoting016DBB07' "
+ "to='user@gmail.com/chromiumsy5C6A652D' type='set' "
+ "xmlns:cli='jabber:client'><jingle action='$1' "
+ "sid='2227053353' xmlns='urn:xmpp:jingle:1'>"
+ "<gr:attachments xmlns:gr='google:remoting'>"
+ "<gr:sometag>some-message</gr:sometag>"
+ "</gr:attachments>$2</jingle></cli:iq>";
+ for (int i = JingleMessage::SESSION_INITIATE;
+ i <= JingleMessage::TRANSPORT_INFO; i++) {
+ JingleMessage::ActionType action_type =
+ static_cast<JingleMessage::ActionType>(i);
+ std::vector<std::string> substitutes = {
+ JingleMessage::GetActionName(action_type)
+ };
+ if (action_type == JingleMessage::SESSION_INFO) {
+ substitutes.push_back("<test-info>test-message</test-info>");
+ } else if (action_type == JingleMessage::SESSION_TERMINATE) {
+ substitutes.emplace_back();
+ } else if (action_type == JingleMessage::TRANSPORT_INFO) {
+ substitutes.push_back(
+ "<content name='chromoting' creator='initiator'>"
+ "<transport xmlns='google:remoting:webrtc'>"
+ "<credentials channel='event' ufrag='tPUyEAmQrEw3y7hi' "
+ "password='2iRdhLfawKZC5ydJ'/>"
+ "<credentials channel='video' ufrag='EPK3CXo5sTLJSez0' "
+ "password='eM0VUfUkZ+1Pyi0M'/>"
+ "<candidate name='event' foundation='725747215' "
+ "address='172.23.164.186' port='59089' type='local' "
+ "protocol='udp' priority='2122194688' generation='0'/>"
+ "<candidate name='video' foundation='3623806809' "
+ "address='172.23.164.186' port='57040' type='local' "
+ "protocol='udp' priority='2122194688' generation='0'/>"
+ "</transport>"
+ "</content>");
+ } else {
+ substitutes.push_back("<content name='chromoting' creator='initiator'>"
+ "<description xmlns='google:remoting'>"
+ "<authentication><auth-token>"
+ "j7whCMii0Z0AAPwj7whCM/j7whCMii0Z0AAPw="
+ "</auth-token></authentication>"
+ "</description>"
+ "<transport xmlns='google:remoting:webrtc' />"
+ "</content>");
+ }
+ std::string message_str = base::ReplaceStringPlaceholders(
+ kMessageWithPluginTag, substitutes, nullptr);
+
+ JingleMessage message;
+ ParseFormatAndCompare(message_str.c_str(), &message);
+
+ EXPECT_TRUE(message.attachments);
+ XmlElement expected(QName("google:remoting", "attachments"));
+ expected.AddElement(new XmlElement(QName("google:remoting", "sometag")));
+ expected.FirstElement()->SetBodyText("some-message");
+ std::string error;
+ EXPECT_TRUE(VerifyXml(&expected, message.attachments.get(), &error))
+ << error;
+ }
+}
+
} // namespace protocol
} // namespace remoting
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698