1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/host_experiment_session_plugin.h"
#include <memory>
#include "base/functional/bind.h"
#include "remoting/base/constants.h"
#include "remoting/host/host_attributes.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
using jingle_xmpp::QName;
using jingle_xmpp::XmlElement;
namespace remoting {
TEST(HostExperimentSessionPluginTest, AttachAttributes) {
HostExperimentSessionPlugin plugin;
std::unique_ptr<XmlElement> attachments = plugin.GetNextMessage();
ASSERT_TRUE(attachments);
ASSERT_EQ(attachments->Name(),
QName(kChromotingXmlNamespace, "host-attributes"));
ASSERT_EQ(attachments->BodyText(), GetHostAttributes());
attachments.reset();
attachments = plugin.GetNextMessage();
ASSERT_FALSE(attachments);
}
TEST(HostExperimentSessionPluginTest, LoadConfiguration) {
std::unique_ptr<XmlElement> attachment(
new XmlElement(QName(kChromotingXmlNamespace, "attachments")));
XmlElement* configuration =
new XmlElement(QName(kChromotingXmlNamespace, "host-configuration"));
configuration->SetBodyText("This Is A Test Configuration");
attachment->AddElement(configuration);
HostExperimentSessionPlugin plugin;
plugin.OnIncomingMessage(*attachment);
ASSERT_TRUE(plugin.configuration_received());
ASSERT_EQ(plugin.configuration(), "This Is A Test Configuration");
}
TEST(HostExperimentSessionPluginTest, IgnoreSecondConfiguration) {
std::unique_ptr<XmlElement> attachment(
new XmlElement(QName(kChromotingXmlNamespace, "attachments")));
XmlElement* configuration =
new XmlElement(QName(kChromotingXmlNamespace, "host-configuration"));
attachment->AddElement(configuration);
configuration->SetBodyText("config1");
HostExperimentSessionPlugin plugin;
plugin.OnIncomingMessage(*attachment);
ASSERT_TRUE(plugin.configuration_received());
ASSERT_EQ(plugin.configuration(), "config1");
configuration->SetBodyText("config2");
plugin.OnIncomingMessage(*attachment);
ASSERT_TRUE(plugin.configuration_received());
ASSERT_EQ(plugin.configuration(), "config1");
}
} // namespace remoting
|