MD Downloads: prevent search text from overlapping with the cancel search (X)
[chromium-blink-merge.git] / remoting / protocol / content_description_unittest.cc
blobeebc39e967f4874f3a89e0ba627fb63745cbc103
1 // Copyright (c) 2012 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.
5 #include "remoting/protocol/content_description.h"
7 #include <string>
9 #include "base/logging.h"
10 #include "remoting/protocol/authenticator.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
15 namespace remoting {
16 namespace protocol {
18 TEST(ContentDescriptionTest, FormatAndParse) {
19 scoped_ptr<CandidateSessionConfig> config =
20 CandidateSessionConfig::CreateDefault();
21 ContentDescription description(
22 config.Pass(), Authenticator::CreateEmptyAuthenticatorMessage(),
23 "TestQuicConfigMessage");
24 scoped_ptr<buzz::XmlElement> xml(description.ToXml());
25 LOG(ERROR) << xml->Str();
26 scoped_ptr<ContentDescription> parsed(
27 ContentDescription::ParseXml(xml.get()));
28 ASSERT_TRUE(parsed.get());
29 EXPECT_TRUE(description.config()->control_configs() ==
30 parsed->config()->control_configs());
31 EXPECT_TRUE(description.config()->video_configs() ==
32 parsed->config()->video_configs());
33 EXPECT_TRUE(description.config()->event_configs() ==
34 parsed->config()->event_configs());
35 EXPECT_TRUE(description.config()->audio_configs() ==
36 parsed->config()->audio_configs());
37 EXPECT_TRUE(description.quic_config_message() ==
38 parsed->quic_config_message());
41 // Verify that we can still parse configs with transports that we don't
42 // recognize.
43 TEST(ContentDescriptionTest, ParseUnknown) {
44 std::string kTestDescription =
45 "<description xmlns=\"google:remoting\">"
46 " <control transport=\"stream\" version=\"2\"/>"
47 " <event transport=\"stream\" version=\"2\"/>"
48 " <event transport=\"new_awesome_transport\" version=\"3\"/>"
49 " <video transport=\"stream\" version=\"2\" codec=\"vp8\"/>"
50 " <authentication/>"
51 "</description>";
52 scoped_ptr<buzz::XmlElement> xml(buzz::XmlElement::ForStr(kTestDescription));
53 scoped_ptr<ContentDescription> parsed(
54 ContentDescription::ParseXml(xml.get()));
55 ASSERT_TRUE(parsed.get());
56 EXPECT_EQ(1U, parsed->config()->event_configs().size());
57 EXPECT_TRUE(parsed->config()->event_configs().front() ==
58 ChannelConfig(ChannelConfig::TRANSPORT_STREAM,
59 kDefaultStreamVersion,
60 ChannelConfig::CODEC_UNDEFINED));
63 // Verify that we can parse configs with none transport without version and
64 // codec.
65 TEST(ContentDescriptionTest, NoneTransport) {
66 std::string kTestDescription =
67 "<description xmlns=\"google:remoting\">"
68 " <control transport=\"stream\" version=\"2\"/>"
69 " <event transport=\"stream\" version=\"2\"/>"
70 " <event transport=\"stream\" version=\"2\"/>"
71 " <video transport=\"stream\" version=\"2\" codec=\"vp8\"/>"
72 " <audio transport=\"none\"/>"
73 " <authentication/>"
74 "</description>";
75 scoped_ptr<buzz::XmlElement> xml(buzz::XmlElement::ForStr(kTestDescription));
76 scoped_ptr<ContentDescription> parsed(
77 ContentDescription::ParseXml(xml.get()));
78 ASSERT_TRUE(parsed.get());
79 EXPECT_EQ(1U, parsed->config()->audio_configs().size());
80 EXPECT_TRUE(parsed->config()->audio_configs().front() == ChannelConfig());
83 // Verify that we can parse configs with none transport with version and
84 // codec.
85 TEST(ContentDescriptionTest, NoneTransportWithCodec) {
86 std::string kTestDescription =
87 "<description xmlns=\"google:remoting\">"
88 " <control transport=\"stream\" version=\"2\"/>"
89 " <event transport=\"stream\" version=\"2\"/>"
90 " <event transport=\"stream\" version=\"2\"/>"
91 " <video transport=\"stream\" version=\"2\" codec=\"vp8\"/>"
92 " <audio transport=\"none\" version=\"2\" codec=\"verbatim\"/>"
93 " <authentication/>"
94 "</description>";
95 scoped_ptr<buzz::XmlElement> xml(buzz::XmlElement::ForStr(kTestDescription));
96 scoped_ptr<ContentDescription> parsed(
97 ContentDescription::ParseXml(xml.get()));
98 ASSERT_TRUE(parsed.get());
99 EXPECT_EQ(1U, parsed->config()->audio_configs().size());
100 EXPECT_TRUE(parsed->config()->audio_configs().front() == ChannelConfig());
103 } // namespace protocol
104 } // namespace remoting