| OLD | NEW |
| (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/host/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 | |
| 20 TEST(HostExperimentSessionPluginTest, AttachAttributes) { | |
| 21 HostExperimentSessionPlugin plugin; | |
| 22 std::unique_ptr<XmlElement> attachments = plugin.GetNextMessage(); | |
| 23 ASSERT_TRUE(attachments); | |
| 24 ASSERT_EQ(attachments->Name(), | |
| 25 QName(kChromotingXmlNamespace, "host-attributes")); | |
| 26 ASSERT_EQ(attachments->BodyText(), GetHostAttributes()); | |
| 27 | |
| 28 attachments.reset(); | |
| 29 attachments = plugin.GetNextMessage(); | |
| 30 ASSERT_FALSE(attachments); | |
| 31 } | |
| 32 | |
| 33 TEST(HostExperimentSessionPluginTest, LoadConfiguration) { | |
| 34 std::unique_ptr<XmlElement> attachment( | |
| 35 new XmlElement(QName(kChromotingXmlNamespace, "attachments"))); | |
| 36 XmlElement* configuration = | |
| 37 new XmlElement(QName(kChromotingXmlNamespace, "host-configuration")); | |
| 38 configuration->SetBodyText("This Is A Test Configuration"); | |
| 39 attachment->AddElement(configuration); | |
| 40 HostExperimentSessionPlugin plugin; | |
| 41 plugin.OnIncomingMessage(*attachment); | |
| 42 ASSERT_TRUE(plugin.configuration_received()); | |
| 43 ASSERT_EQ(plugin.configuration(), "This Is A Test Configuration"); | |
| 44 } | |
| 45 | |
| 46 TEST(HostExperimentSessionPluginTest, IgnoreSecondConfiguration) { | |
| 47 std::unique_ptr<XmlElement> attachment( | |
| 48 new XmlElement(QName(kChromotingXmlNamespace, "attachments"))); | |
| 49 XmlElement* configuration = | |
| 50 new XmlElement(QName(kChromotingXmlNamespace, "host-configuration")); | |
| 51 attachment->AddElement(configuration); | |
| 52 configuration->SetBodyText("config1"); | |
| 53 HostExperimentSessionPlugin plugin; | |
| 54 plugin.OnIncomingMessage(*attachment); | |
| 55 ASSERT_TRUE(plugin.configuration_received()); | |
| 56 ASSERT_EQ(plugin.configuration(), "config1"); | |
| 57 | |
| 58 configuration->SetBodyText("config2"); | |
| 59 plugin.OnIncomingMessage(*attachment); | |
| 60 ASSERT_TRUE(plugin.configuration_received()); | |
| 61 ASSERT_EQ(plugin.configuration(), "config1"); | |
| 62 } | |
| 63 | |
| 64 } // namespace remoting | |
| OLD | NEW |