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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/protocol/host_experiment_session_plugin.h"
6
7 #include <memory>
8
9 #include "base/bind.h"
10 #include "remoting/base/constants.h"
11 #include "remoting/host/host_attributes.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
14
15 using buzz::QName;
16 using buzz::XmlElement;
17
18 namespace remoting {
19 namespace protocol {
20
21 namespace {
22
23 constexpr char XmlNamespace[] = "TestXmlNamespace";
24 constexpr char XmlTagName[] = "TestXmlTagName";
25
26 std::unique_ptr<XmlElement> NewAttachment() {
27 return std::unique_ptr<XmlElement>(
28 new XmlElement(QName(XmlNamespace, XmlTagName)));
29 }
30
31 } // namespace
32
33 TEST(HostExperimentSessionPluginTest, AttachAttributes) {
34 HostExperimentSessionPlugin plugin(base::Bind(&NewAttachment));
35 std::unique_ptr<XmlElement> attachments;
36 plugin.OnSending(Session::ACCEPTING, JingleMessage::SESSION_ACCEPT,
37 &attachments);
38 ASSERT_TRUE(attachments);
39 XmlElement* attributes_tag = attachments->FirstNamed(
40 QName(kChromotingXmlNamespace, "host-attributes"));
41 ASSERT_TRUE(attributes_tag);
42 ASSERT_EQ(attributes_tag->BodyText(), GetHostAttributes());
43
44 attachments.reset();
45 plugin.OnSending(Session::AUTHENTICATED, JingleMessage::SESSION_ACCEPT,
46 &attachments);
47 ASSERT_FALSE(attachments);
48 }
49
50 TEST(HostExperimentSessionPluginTest, LoadConfiguration) {
51 std::unique_ptr<XmlElement> attachment = NewAttachment();
52 XmlElement* configuration =
53 new XmlElement(QName(kChromotingXmlNamespace, "host-configuration"));
54 configuration->SetBodyText("This Is A Test Configuration");
55 attachment->AddElement(configuration);
56 {
57 HostExperimentSessionPlugin plugin(base::Bind(&NewAttachment));
58 plugin.OnReceiving(Session::AUTHENTICATING, JingleMessage::SESSION_INFO,
59 attachment);
60 ASSERT_EQ(plugin.configuration(), "This Is A Test Configuration");
61 }
62 {
63 HostExperimentSessionPlugin plugin(base::Bind(&NewAttachment));
64 plugin.OnReceiving(Session::AUTHENTICATED, JingleMessage::SESSION_INFO,
65 attachment);
66 ASSERT_TRUE(plugin.configuration().empty());
67 }
68 }
69
70 } // namespace protocol
71 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698