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

Unified Diff: remoting/protocol/host_experiment_session_plugin_unittest.cc

Issue 2586133002: [Chromoting] Implement HostExperimentSessionPlugin (Closed)
Patch Set: 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
Index: remoting/protocol/host_experiment_session_plugin_unittest.cc
diff --git a/remoting/protocol/host_experiment_session_plugin_unittest.cc b/remoting/protocol/host_experiment_session_plugin_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..af64226e2523f9e2b0c1b1e52c74811437d28c51
--- /dev/null
+++ b/remoting/protocol/host_experiment_session_plugin_unittest.cc
@@ -0,0 +1,71 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/host_experiment_session_plugin.h"
+
+#include <memory>
+
+#include "base/bind.h"
+#include "remoting/base/constants.h"
+#include "remoting/host/host_attributes.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
+
+using buzz::QName;
+using buzz::XmlElement;
+
+namespace remoting {
+namespace protocol {
+
+namespace {
+
+constexpr char XmlNamespace[] = "TestXmlNamespace";
+constexpr char XmlTagName[] = "TestXmlTagName";
+
+std::unique_ptr<XmlElement> NewAttachment() {
+ return std::unique_ptr<XmlElement>(
+ new XmlElement(QName(XmlNamespace, XmlTagName)));
+}
+
+} // namespace
+
+TEST(HostExperimentSessionPluginTest, AttachAttributes) {
+ HostExperimentSessionPlugin plugin(base::Bind(&NewAttachment));
+ std::unique_ptr<XmlElement> attachments;
+ plugin.OnSending(Session::ACCEPTING, JingleMessage::SESSION_ACCEPT,
+ &attachments);
+ ASSERT_TRUE(attachments);
+ XmlElement* attributes_tag = attachments->FirstNamed(
+ QName(kChromotingXmlNamespace, "host-attributes"));
+ ASSERT_TRUE(attributes_tag);
+ ASSERT_EQ(attributes_tag->BodyText(), GetHostAttributes());
+
+ attachments.reset();
+ plugin.OnSending(Session::AUTHENTICATED, JingleMessage::SESSION_ACCEPT,
+ &attachments);
+ ASSERT_FALSE(attachments);
+}
+
+TEST(HostExperimentSessionPluginTest, LoadConfiguration) {
+ std::unique_ptr<XmlElement> attachment = NewAttachment();
+ XmlElement* configuration =
+ new XmlElement(QName(kChromotingXmlNamespace, "host-configuration"));
+ configuration->SetBodyText("This Is A Test Configuration");
+ attachment->AddElement(configuration);
+ {
+ HostExperimentSessionPlugin plugin(base::Bind(&NewAttachment));
+ plugin.OnReceiving(Session::AUTHENTICATING, JingleMessage::SESSION_INFO,
+ attachment);
+ ASSERT_EQ(plugin.configuration(), "This Is A Test Configuration");
+ }
+ {
+ HostExperimentSessionPlugin plugin(base::Bind(&NewAttachment));
+ plugin.OnReceiving(Session::AUTHENTICATED, JingleMessage::SESSION_INFO,
+ attachment);
+ ASSERT_TRUE(plugin.configuration().empty());
+ }
+}
+
+} // namespace protocol
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698